2002-01-07 18:08:28 +03:00
/*
* Copyright ( C ) 2001 Sistina Software
*
* This file is released under the LGPL .
*/
2002-11-18 17:04:08 +03:00
# include "lib.h"
2002-01-10 21:12:26 +03:00
# include "metadata.h"
2002-01-07 18:08:28 +03:00
/*
* Returns success if the segments were
* successfully merged . If the do merge , ' first '
* will be adjusted to contain both areas .
*/
2002-11-18 17:04:08 +03:00
static int _merge ( struct lv_segment * first , struct lv_segment * second )
2002-01-07 18:08:28 +03:00
{
2002-12-20 02:25:55 +03:00
unsigned int s ;
2002-01-07 18:08:28 +03:00
uint32_t width ;
if ( ! first | |
2002-11-18 17:04:08 +03:00
( first - > type ! = SEG_STRIPED ) | |
( first - > type ! = second - > type ) | |
2002-01-07 18:08:28 +03:00
( first - > stripes ! = second - > stripes ) | |
( first - > stripe_size ! = second - > stripe_size ) )
return 0 ;
for ( s = 0 ; s < first - > stripes ; s + + ) {
width = first - > len / first - > stripes ;
if ( ( first - > area [ s ] . pv ! = second - > area [ s ] . pv ) | |
( first - > area [ s ] . pe + width ! = second - > area [ s ] . pe ) )
return 0 ;
}
/* we should merge */
first - > len + = second - > len ;
return 1 ;
}
2002-01-10 14:18:08 +03:00
int lv_merge_segments ( struct logical_volume * lv )
2002-01-07 18:08:28 +03:00
{
struct list * segh ;
2002-11-18 17:04:08 +03:00
struct lv_segment * current , * prev = NULL ;
2002-01-07 18:08:28 +03:00
2002-04-24 22:20:51 +04:00
list_iterate ( segh , & lv - > segments ) {
2002-11-18 17:04:08 +03:00
current = list_item ( segh , struct lv_segment ) ;
2002-01-07 18:08:28 +03:00
if ( _merge ( prev , current ) )
list_del ( & current - > list ) ;
else
prev = current ;
}
return 1 ;
}
2002-01-11 02:21:07 +03:00
int lv_check_segments ( struct logical_volume * lv )
{
return 1 ;
}