105105 *
106106 */
107107
108+ typedef __u16 bitmap_counter_t ;
109+
108110#define PAGE_BITS (PAGE_SIZE << 3)
109111#define PAGE_BIT_SHIFT (PAGE_SHIFT + 3)
110112
113+ #define COUNTER_BITS 16
114+ #define COUNTER_BIT_SHIFT 4
115+ #define COUNTER_BYTE_SHIFT (COUNTER_BIT_SHIFT - 3)
116+
117+ #define NEEDED_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 1)))
118+ #define RESYNC_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 2)))
119+ #define COUNTER_MAX ((bitmap_counter_t) RESYNC_MASK - 1)
120+
111121#define NEEDED (x ) (((bitmap_counter_t) x) & NEEDED_MASK)
112122#define RESYNC (x ) (((bitmap_counter_t) x) & RESYNC_MASK)
113123#define COUNTER (x ) (((bitmap_counter_t) x) & COUNTER_MAX)
@@ -789,7 +799,7 @@ static int md_bitmap_new_disk_sb(struct bitmap *bitmap)
789799 * is a good choice? We choose COUNTER_MAX / 2 arbitrarily.
790800 */
791801 write_behind = bitmap -> mddev -> bitmap_info .max_write_behind ;
792- if (write_behind > COUNTER_MAX )
802+ if (write_behind > COUNTER_MAX / 2 )
793803 write_behind = COUNTER_MAX / 2 ;
794804 sb -> write_behind = cpu_to_le32 (write_behind );
795805 bitmap -> mddev -> bitmap_info .max_write_behind = write_behind ;
@@ -1672,13 +1682,13 @@ __acquires(bitmap->lock)
16721682 & (bitmap -> bp [page ].map [pageoff ]);
16731683}
16741684
1675- static int bitmap_startwrite (struct mddev * mddev , sector_t offset ,
1676- unsigned long sectors )
1685+ static void bitmap_start_write (struct mddev * mddev , sector_t offset ,
1686+ unsigned long sectors )
16771687{
16781688 struct bitmap * bitmap = mddev -> bitmap ;
16791689
16801690 if (!bitmap )
1681- return 0 ;
1691+ return ;
16821692
16831693 while (sectors ) {
16841694 sector_t blocks ;
@@ -1688,7 +1698,7 @@ static int bitmap_startwrite(struct mddev *mddev, sector_t offset,
16881698 bmc = md_bitmap_get_counter (& bitmap -> counts , offset , & blocks , 1 );
16891699 if (!bmc ) {
16901700 spin_unlock_irq (& bitmap -> counts .lock );
1691- return 0 ;
1701+ return ;
16921702 }
16931703
16941704 if (unlikely (COUNTER (* bmc ) == COUNTER_MAX )) {
@@ -1724,11 +1734,10 @@ static int bitmap_startwrite(struct mddev *mddev, sector_t offset,
17241734 else
17251735 sectors = 0 ;
17261736 }
1727- return 0 ;
17281737}
17291738
1730- static void bitmap_endwrite (struct mddev * mddev , sector_t offset ,
1731- unsigned long sectors )
1739+ static void bitmap_end_write (struct mddev * mddev , sector_t offset ,
1740+ unsigned long sectors )
17321741{
17331742 struct bitmap * bitmap = mddev -> bitmap ;
17341743
@@ -2205,9 +2214,9 @@ static struct bitmap *__bitmap_create(struct mddev *mddev, int slot)
22052214 return ERR_PTR (err );
22062215}
22072216
2208- static int bitmap_create (struct mddev * mddev , int slot )
2217+ static int bitmap_create (struct mddev * mddev )
22092218{
2210- struct bitmap * bitmap = __bitmap_create (mddev , slot );
2219+ struct bitmap * bitmap = __bitmap_create (mddev , -1 );
22112220
22122221 if (IS_ERR (bitmap ))
22132222 return PTR_ERR (bitmap );
@@ -2670,7 +2679,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
26702679 }
26712680
26722681 mddev -> bitmap_info .offset = offset ;
2673- rv = bitmap_create (mddev , -1 );
2682+ rv = bitmap_create (mddev );
26742683 if (rv )
26752684 goto out ;
26762685
@@ -3003,8 +3012,8 @@ static struct bitmap_operations bitmap_ops = {
30033012 .end_behind_write = bitmap_end_behind_write ,
30043013 .wait_behind_writes = bitmap_wait_behind_writes ,
30053014
3006- .startwrite = bitmap_startwrite ,
3007- .endwrite = bitmap_endwrite ,
3015+ .start_write = bitmap_start_write ,
3016+ .end_write = bitmap_end_write ,
30083017 .start_sync = bitmap_start_sync ,
30093018 .end_sync = bitmap_end_sync ,
30103019 .cond_end_sync = bitmap_cond_end_sync ,
0 commit comments