Draft: libdm refactor: consolidate device_mapper and base directories into libdm
libdm refactor: consolidate device_mapper and base directories into libdm
Overview
This merge request implements a major refactoring of the LVM2 codebase to consolidate the device_mapper and base directories into the existing libdm directory. This consolidation simplifies the codebase structure, reduces duplication, and provides a cleaner API surface for device mapper functionality.
Summary of Changes
The refactoring consists of 22 commits that systematically:
- Sync existing libdm components with their device_mapper counterparts to ensure feature parity
- Add missing functionality from device_mapper to libdm (RAID, VDO, integrity, cache, writecache)
- Consolidate base directory utilities (hash, radix tree, container_of) into libdm
- Remove redundant directories (device_mapper and base) after successful migration
- Update all references throughout the codebase to use the consolidated libdm API
Key Changes
New Functionality Added to libdm:
-
RAID support: Added RAID target functionality with
dm_raid_count_failed_devicesanddm_raid_clear_failed_devicesfunctions - VDO support: Integrated VDO target functionality for data deduplication
- Integrity support: Added integrity target functionality for data integrity checking
- Cache/Writecache support: Integrated cache and writecache target functionality
- Enhanced data structures: Added radix tree implementation and updated hash implementation
-
Utility functions: Added
dm_container_ofmacro anddm_active_devicesupport
Code Consolidation:
- Removed ~26,000 lines of duplicated code from device_mapper and base directories
- Added ~2,000 lines of consolidated functionality to libdm
- Updated 158 files across the codebase to use the new libdm API
- Maintained backward compatibility through proper function naming and API design
API Improvements:
- All device mapper functionality now accessible through a single
libdevmapper.hheader - Consistent naming convention with
dm_prefix for all functions - Cleaner separation of concerns within the libdm directory structure
- Enhanced logging and debugging capabilities
Benefits
- Simplified maintenance: Single source of truth for device mapper functionality
- Reduced code duplication: Eliminated redundant implementations across directories
- Better API design: Consistent interface through libdm
- Easier testing: Consolidated test suite for all device mapper functionality
- Improved build system: Simplified Makefile structure and dependencies
Testing
The refactoring maintains full backward compatibility and all existing functionality. The changes have been tested to ensure:
- All LVM2 commands continue to work as expected
- Device mapper operations function correctly
- No regressions in existing functionality
- Proper compilation across different build configurations
mpact
This refactoring represents a significant step forward in code organization and maintainability for the LVM2 project, providing a solid foundation for future development while maintaining full backward compatibility.
Type: Refactoring
Scope: libdm consolidation
Breaking Changes: None (backward compatible)
Files Changed: 158 files
Lines Added: ~2,000
Lines Removed: ~26,000