Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
5d81a787
Commit
5d81a787
authored
Aug 01, 2018
by
Dmitry Torokhov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ib/4.17-bitmap' into next
Bring in bitmap API improvements.
parents
955c594e
c42b65e3
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
316 additions
and
304 deletions
+316
-304
drivers/md/dm-raid.c
drivers/md/dm-raid.c
+3
-3
drivers/md/md-bitmap.c
drivers/md/md-bitmap.c
+148
-157
drivers/md/md-bitmap.h
drivers/md/md-bitmap.h
+30
-30
drivers/md/md-cluster.c
drivers/md/md-cluster.c
+8
-10
drivers/md/md.c
drivers/md/md.c
+22
-22
drivers/md/persistent-data/dm-space-map-common.c
drivers/md/persistent-data/dm-space-map-common.c
+10
-10
drivers/md/raid1.c
drivers/md/raid1.c
+16
-19
drivers/md/raid10.c
drivers/md/raid10.c
+25
-27
drivers/md/raid5-cache.c
drivers/md/raid5-cache.c
+4
-4
drivers/md/raid5.c
drivers/md/raid5.c
+22
-22
include/linux/bitmap.h
include/linux/bitmap.h
+8
-0
lib/bitmap.c
lib/bitmap.c
+20
-0
No files found.
drivers/md/dm-raid.c
View file @
5d81a787
...
@@ -3859,7 +3859,7 @@ static int __load_dirty_region_bitmap(struct raid_set *rs)
...
@@ -3859,7 +3859,7 @@ static int __load_dirty_region_bitmap(struct raid_set *rs)
/* Try loading the bitmap unless "raid0", which does not have one */
/* Try loading the bitmap unless "raid0", which does not have one */
if
(
!
rs_is_raid0
(
rs
)
&&
if
(
!
rs_is_raid0
(
rs
)
&&
!
test_and_set_bit
(
RT_FLAG_RS_BITMAP_LOADED
,
&
rs
->
runtime_flags
))
{
!
test_and_set_bit
(
RT_FLAG_RS_BITMAP_LOADED
,
&
rs
->
runtime_flags
))
{
r
=
bitmap_load
(
&
rs
->
md
);
r
=
md_
bitmap_load
(
&
rs
->
md
);
if
(
r
)
if
(
r
)
DMERR
(
"Failed to load bitmap"
);
DMERR
(
"Failed to load bitmap"
);
}
}
...
@@ -3987,7 +3987,7 @@ static int raid_preresume(struct dm_target *ti)
...
@@ -3987,7 +3987,7 @@ static int raid_preresume(struct dm_target *ti)
/* Resize bitmap to adjust to changed region size (aka MD bitmap chunksize) */
/* Resize bitmap to adjust to changed region size (aka MD bitmap chunksize) */
if
(
test_bit
(
RT_FLAG_RS_BITMAP_LOADED
,
&
rs
->
runtime_flags
)
&&
mddev
->
bitmap
&&
if
(
test_bit
(
RT_FLAG_RS_BITMAP_LOADED
,
&
rs
->
runtime_flags
)
&&
mddev
->
bitmap
&&
mddev
->
bitmap_info
.
chunksize
!=
to_bytes
(
rs
->
requested_bitmap_chunk_sectors
))
{
mddev
->
bitmap_info
.
chunksize
!=
to_bytes
(
rs
->
requested_bitmap_chunk_sectors
))
{
r
=
bitmap_resize
(
mddev
->
bitmap
,
mddev
->
dev_sectors
,
r
=
md_
bitmap_resize
(
mddev
->
bitmap
,
mddev
->
dev_sectors
,
to_bytes
(
rs
->
requested_bitmap_chunk_sectors
),
0
);
to_bytes
(
rs
->
requested_bitmap_chunk_sectors
),
0
);
if
(
r
)
if
(
r
)
DMERR
(
"Failed to resize bitmap"
);
DMERR
(
"Failed to resize bitmap"
);
...
...
drivers/md/md-bitmap.c
View file @
5d81a787
...
@@ -46,7 +46,7 @@ static inline char *bmname(struct bitmap *bitmap)
...
@@ -46,7 +46,7 @@ static inline char *bmname(struct bitmap *bitmap)
* if we find our page, we increment the page's refcount so that it stays
* if we find our page, we increment the page's refcount so that it stays
* allocated while we're using it
* allocated while we're using it
*/
*/
static
int
bitmap_checkpage
(
struct
bitmap_counts
*
bitmap
,
static
int
md_
bitmap_checkpage
(
struct
bitmap_counts
*
bitmap
,
unsigned
long
page
,
int
create
,
int
no_hijack
)
unsigned
long
page
,
int
create
,
int
no_hijack
)
__releases
(
bitmap
->
lock
)
__releases
(
bitmap
->
lock
)
__acquires
(
bitmap
->
lock
)
__acquires
(
bitmap
->
lock
)
...
@@ -115,7 +115,7 @@ __acquires(bitmap->lock)
...
@@ -115,7 +115,7 @@ __acquires(bitmap->lock)
/* if page is completely empty, put it back on the free list, or dealloc it */
/* if page is completely empty, put it back on the free list, or dealloc it */
/* if page was hijacked, unmark the flag so it might get alloced next time */
/* if page was hijacked, unmark the flag so it might get alloced next time */
/* Note: lock should be held when calling this */
/* Note: lock should be held when calling this */
static
void
bitmap_checkfree
(
struct
bitmap_counts
*
bitmap
,
unsigned
long
page
)
static
void
md_
bitmap_checkfree
(
struct
bitmap_counts
*
bitmap
,
unsigned
long
page
)
{
{
char
*
ptr
;
char
*
ptr
;
...
@@ -280,7 +280,7 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
...
@@ -280,7 +280,7 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
return
-
EINVAL
;
return
-
EINVAL
;
}
}
static
void
bitmap_file_kick
(
struct
bitmap
*
bitmap
);
static
void
md_
bitmap_file_kick
(
struct
bitmap
*
bitmap
);
/*
/*
* write out a page to a file
* write out a page to a file
*/
*/
...
@@ -310,7 +310,7 @@ static void write_page(struct bitmap *bitmap, struct page *page, int wait)
...
@@ -310,7 +310,7 @@ static void write_page(struct bitmap *bitmap, struct page *page, int wait)
atomic_read
(
&
bitmap
->
pending_writes
)
==
0
);
atomic_read
(
&
bitmap
->
pending_writes
)
==
0
);
}
}
if
(
test_bit
(
BITMAP_WRITE_ERROR
,
&
bitmap
->
flags
))
if
(
test_bit
(
BITMAP_WRITE_ERROR
,
&
bitmap
->
flags
))
bitmap_file_kick
(
bitmap
);
md_
bitmap_file_kick
(
bitmap
);
}
}
static
void
end_bitmap_write
(
struct
buffer_head
*
bh
,
int
uptodate
)
static
void
end_bitmap_write
(
struct
buffer_head
*
bh
,
int
uptodate
)
...
@@ -421,11 +421,11 @@ static int read_page(struct file *file, unsigned long index,
...
@@ -421,11 +421,11 @@ static int read_page(struct file *file, unsigned long index,
*/
*/
/*
/*
* bitmap_wait_writes() should be called before writing any bitmap
*
md_
bitmap_wait_writes() should be called before writing any bitmap
* blocks, to ensure previous writes, particularly from
* blocks, to ensure previous writes, particularly from
* bitmap_daemon_work(), have completed.
*
md_
bitmap_daemon_work(), have completed.
*/
*/
static
void
bitmap_wait_writes
(
struct
bitmap
*
bitmap
)
static
void
md_
bitmap_wait_writes
(
struct
bitmap
*
bitmap
)
{
{
if
(
bitmap
->
storage
.
file
)
if
(
bitmap
->
storage
.
file
)
wait_event
(
bitmap
->
write_wait
,
wait_event
(
bitmap
->
write_wait
,
...
@@ -443,7 +443,7 @@ static void bitmap_wait_writes(struct bitmap *bitmap)
...
@@ -443,7 +443,7 @@ static void bitmap_wait_writes(struct bitmap *bitmap)
/* update the event counter and sync the superblock to disk */
/* update the event counter and sync the superblock to disk */
void
bitmap_update_sb
(
struct
bitmap
*
bitmap
)
void
md_
bitmap_update_sb
(
struct
bitmap
*
bitmap
)
{
{
bitmap_super_t
*
sb
;
bitmap_super_t
*
sb
;
...
@@ -476,10 +476,10 @@ void bitmap_update_sb(struct bitmap *bitmap)
...
@@ -476,10 +476,10 @@ void bitmap_update_sb(struct bitmap *bitmap)
kunmap_atomic
(
sb
);
kunmap_atomic
(
sb
);
write_page
(
bitmap
,
bitmap
->
storage
.
sb_page
,
1
);
write_page
(
bitmap
,
bitmap
->
storage
.
sb_page
,
1
);
}
}
EXPORT_SYMBOL
(
bitmap_update_sb
);
EXPORT_SYMBOL
(
md_
bitmap_update_sb
);
/* print out the bitmap file superblock */
/* print out the bitmap file superblock */
void
bitmap_print_sb
(
struct
bitmap
*
bitmap
)
void
md_
bitmap_print_sb
(
struct
bitmap
*
bitmap
)
{
{
bitmap_super_t
*
sb
;
bitmap_super_t
*
sb
;
...
@@ -518,7 +518,7 @@ void bitmap_print_sb(struct bitmap *bitmap)
...
@@ -518,7 +518,7 @@ void bitmap_print_sb(struct bitmap *bitmap)
*
*
* Returns: 0 on success, -Exxx on error
* Returns: 0 on success, -Exxx on error
*/
*/
static
int
bitmap_new_disk_sb
(
struct
bitmap
*
bitmap
)
static
int
md_
bitmap_new_disk_sb
(
struct
bitmap
*
bitmap
)
{
{
bitmap_super_t
*
sb
;
bitmap_super_t
*
sb
;
unsigned
long
chunksize
,
daemon_sleep
,
write_behind
;
unsigned
long
chunksize
,
daemon_sleep
,
write_behind
;
...
@@ -577,7 +577,7 @@ static int bitmap_new_disk_sb(struct bitmap *bitmap)
...
@@ -577,7 +577,7 @@ static int bitmap_new_disk_sb(struct bitmap *bitmap)
}
}
/* read the superblock from the bitmap file and initialize some bitmap fields */
/* read the superblock from the bitmap file and initialize some bitmap fields */
static
int
bitmap_read_sb
(
struct
bitmap
*
bitmap
)
static
int
md_
bitmap_read_sb
(
struct
bitmap
*
bitmap
)
{
{
char
*
reason
=
NULL
;
char
*
reason
=
NULL
;
bitmap_super_t
*
sb
;
bitmap_super_t
*
sb
;
...
@@ -727,7 +727,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
...
@@ -727,7 +727,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
bitmap
->
mddev
->
bitmap_info
.
space
>
sectors_reserved
)
bitmap
->
mddev
->
bitmap_info
.
space
>
sectors_reserved
)
bitmap
->
mddev
->
bitmap_info
.
space
=
sectors_reserved
;
bitmap
->
mddev
->
bitmap_info
.
space
=
sectors_reserved
;
if
(
err
)
{
if
(
err
)
{
bitmap_print_sb
(
bitmap
);
md_
bitmap_print_sb
(
bitmap
);
if
(
bitmap
->
cluster_slot
<
0
)
if
(
bitmap
->
cluster_slot
<
0
)
md_cluster_stop
(
bitmap
->
mddev
);
md_cluster_stop
(
bitmap
->
mddev
);
}
}
...
@@ -774,7 +774,7 @@ static inline struct page *filemap_get_page(struct bitmap_storage *store,
...
@@ -774,7 +774,7 @@ static inline struct page *filemap_get_page(struct bitmap_storage *store,
return
store
->
filemap
[
file_page_index
(
store
,
chunk
)];
return
store
->
filemap
[
file_page_index
(
store
,
chunk
)];
}
}
static
int
bitmap_storage_alloc
(
struct
bitmap_storage
*
store
,
static
int
md_
bitmap_storage_alloc
(
struct
bitmap_storage
*
store
,
unsigned
long
chunks
,
int
with_super
,
unsigned
long
chunks
,
int
with_super
,
int
slot_number
)
int
slot_number
)
{
{
...
@@ -830,7 +830,7 @@ static int bitmap_storage_alloc(struct bitmap_storage *store,
...
@@ -830,7 +830,7 @@ static int bitmap_storage_alloc(struct bitmap_storage *store,
return
0
;
return
0
;
}
}
static
void
bitmap_file_unmap
(
struct
bitmap_storage
*
store
)
static
void
md_
bitmap_file_unmap
(
struct
bitmap_storage
*
store
)
{
{
struct
page
**
map
,
*
sb_page
;
struct
page
**
map
,
*
sb_page
;
int
pages
;
int
pages
;
...
@@ -862,12 +862,12 @@ static void bitmap_file_unmap(struct bitmap_storage *store)
...
@@ -862,12 +862,12 @@ static void bitmap_file_unmap(struct bitmap_storage *store)
* then it is no longer reliable, so we stop using it and we mark the file
* then it is no longer reliable, so we stop using it and we mark the file
* as failed in the superblock
* as failed in the superblock
*/
*/
static
void
bitmap_file_kick
(
struct
bitmap
*
bitmap
)
static
void
md_
bitmap_file_kick
(
struct
bitmap
*
bitmap
)
{
{
char
*
path
,
*
ptr
=
NULL
;
char
*
path
,
*
ptr
=
NULL
;
if
(
!
test_and_set_bit
(
BITMAP_STALE
,
&
bitmap
->
flags
))
{
if
(
!
test_and_set_bit
(
BITMAP_STALE
,
&
bitmap
->
flags
))
{
bitmap_update_sb
(
bitmap
);
md_
bitmap_update_sb
(
bitmap
);
if
(
bitmap
->
storage
.
file
)
{
if
(
bitmap
->
storage
.
file
)
{
path
=
kmalloc
(
PAGE_SIZE
,
GFP_KERNEL
);
path
=
kmalloc
(
PAGE_SIZE
,
GFP_KERNEL
);
...
@@ -923,7 +923,7 @@ static inline int test_and_clear_page_attr(struct bitmap *bitmap, int pnum,
...
@@ -923,7 +923,7 @@ static inline int test_and_clear_page_attr(struct bitmap *bitmap, int pnum,
* we set the bit immediately, then we record the page number so that
* we set the bit immediately, then we record the page number so that
* when an unplug occurs, we can flush the dirty pages out to disk
* when an unplug occurs, we can flush the dirty pages out to disk
*/
*/
static
void
bitmap_file_set_bit
(
struct
bitmap
*
bitmap
,
sector_t
block
)
static
void
md_
bitmap_file_set_bit
(
struct
bitmap
*
bitmap
,
sector_t
block
)
{
{
unsigned
long
bit
;
unsigned
long
bit
;
struct
page
*
page
;
struct
page
*
page
;
...
@@ -952,7 +952,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block)
...
@@ -952,7 +952,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block)
set_page_attr
(
bitmap
,
page
->
index
-
node_offset
,
BITMAP_PAGE_DIRTY
);
set_page_attr
(
bitmap
,
page
->
index
-
node_offset
,
BITMAP_PAGE_DIRTY
);
}
}
static
void
bitmap_file_clear_bit
(
struct
bitmap
*
bitmap
,
sector_t
block
)
static
void
md_
bitmap_file_clear_bit
(
struct
bitmap
*
bitmap
,
sector_t
block
)
{
{
unsigned
long
bit
;
unsigned
long
bit
;
struct
page
*
page
;
struct
page
*
page
;
...
@@ -980,7 +980,7 @@ static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block)
...
@@ -980,7 +980,7 @@ static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block)
}
}
}
}
static
int
bitmap_file_test_bit
(
struct
bitmap
*
bitmap
,
sector_t
block
)
static
int
md_
bitmap_file_test_bit
(
struct
bitmap
*
bitmap
,
sector_t
block
)
{
{
unsigned
long
bit
;
unsigned
long
bit
;
struct
page
*
page
;
struct
page
*
page
;
...
@@ -1005,7 +1005,7 @@ static int bitmap_file_test_bit(struct bitmap *bitmap, sector_t block)
...
@@ -1005,7 +1005,7 @@ static int bitmap_file_test_bit(struct bitmap *bitmap, sector_t block)
/* this gets called when the md device is ready to unplug its underlying
/* this gets called when the md device is ready to unplug its underlying
* (slave) device queues -- before we let any writes go down, we need to
* (slave) device queues -- before we let any writes go down, we need to
* sync the dirty pages of the bitmap file to disk */
* sync the dirty pages of the bitmap file to disk */
void
bitmap_unplug
(
struct
bitmap
*
bitmap
)
void
md_
bitmap_unplug
(
struct
bitmap
*
bitmap
)
{
{
unsigned
long
i
;
unsigned
long
i
;
int
dirty
,
need_write
;
int
dirty
,
need_write
;
...
@@ -1025,7 +1025,7 @@ void bitmap_unplug(struct bitmap *bitmap)
...
@@ -1025,7 +1025,7 @@ void bitmap_unplug(struct bitmap *bitmap)
BITMAP_PAGE_NEEDWRITE
);
BITMAP_PAGE_NEEDWRITE
);
if
(
dirty
||
need_write
)
{
if
(
dirty
||
need_write
)
{
if
(
!
writing
)
{
if
(
!
writing
)
{
bitmap_wait_writes
(
bitmap
);
md_
bitmap_wait_writes
(
bitmap
);
if
(
bitmap
->
mddev
->
queue
)
if
(
bitmap
->
mddev
->
queue
)
blk_add_trace_msg
(
bitmap
->
mddev
->
queue
,
blk_add_trace_msg
(
bitmap
->
mddev
->
queue
,
"md bitmap_unplug"
);
"md bitmap_unplug"
);
...
@@ -1036,14 +1036,14 @@ void bitmap_unplug(struct bitmap *bitmap)
...
@@ -1036,14 +1036,14 @@ void bitmap_unplug(struct bitmap *bitmap)
}
}
}
}
if
(
writing
)
if
(
writing
)
bitmap_wait_writes
(
bitmap
);
md_
bitmap_wait_writes
(
bitmap
);
if
(
test_bit
(
BITMAP_WRITE_ERROR
,
&
bitmap
->
flags
))
if
(
test_bit
(
BITMAP_WRITE_ERROR
,
&
bitmap
->
flags
))
bitmap_file_kick
(
bitmap
);
md_
bitmap_file_kick
(
bitmap
);
}
}
EXPORT_SYMBOL
(
bitmap_unplug
);
EXPORT_SYMBOL
(
md_
bitmap_unplug
);
static
void
bitmap_set_memory_bits
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
int
needed
);
static
void
md_
bitmap_set_memory_bits
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
int
needed
);
/* * bitmap_init_from_disk -- called at bitmap_create time to initialize
/* * bitmap_init_from_disk -- called at bitmap_create time to initialize
* the in-memory bitmap from the on-disk bitmap -- also, sets up the
* the in-memory bitmap from the on-disk bitmap -- also, sets up the
* memory mapping of the bitmap file
* memory mapping of the bitmap file
...
@@ -1055,7 +1055,7 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n
...
@@ -1055,7 +1055,7 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n
* We ignore all bits for sectors that end earlier than 'start'.
* We ignore all bits for sectors that end earlier than 'start'.
* This is used when reading an out-of-date bitmap...
* This is used when reading an out-of-date bitmap...
*/
*/
static
int
bitmap_init_from_disk
(
struct
bitmap
*
bitmap
,
sector_t
start
)
static
int
md_
bitmap_init_from_disk
(
struct
bitmap
*
bitmap
,
sector_t
start
)
{
{
unsigned
long
i
,
chunks
,
index
,
oldindex
,
bit
,
node_offset
=
0
;
unsigned
long
i
,
chunks
,
index
,
oldindex
,
bit
,
node_offset
=
0
;
struct
page
*
page
=
NULL
;
struct
page
*
page
=
NULL
;
...
@@ -1078,7 +1078,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
...
@@ -1078,7 +1078,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
/* if the disk bit is set, set the memory bit */
/* if the disk bit is set, set the memory bit */
int
needed
=
((
sector_t
)(
i
+
1
)
<<
(
bitmap
->
counts
.
chunkshift
)
int
needed
=
((
sector_t
)(
i
+
1
)
<<
(
bitmap
->
counts
.
chunkshift
)
>=
start
);
>=
start
);
bitmap_set_memory_bits
(
bitmap
,
md_
bitmap_set_memory_bits
(
bitmap
,
(
sector_t
)
i
<<
bitmap
->
counts
.
chunkshift
,
(
sector_t
)
i
<<
bitmap
->
counts
.
chunkshift
,
needed
);
needed
);
}
}
...
@@ -1159,7 +1159,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
...
@@ -1159,7 +1159,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
/* if the disk bit is set, set the memory bit */
/* if the disk bit is set, set the memory bit */
int
needed
=
((
sector_t
)(
i
+
1
)
<<
bitmap
->
counts
.
chunkshift
int
needed
=
((
sector_t
)(
i
+
1
)
<<
bitmap
->
counts
.
chunkshift
>=
start
);
>=
start
);
bitmap_set_memory_bits
(
bitmap
,
md_
bitmap_set_memory_bits
(
bitmap
,
(
sector_t
)
i
<<
bitmap
->
counts
.
chunkshift
,
(
sector_t
)
i
<<
bitmap
->
counts
.
chunkshift
,
needed
);
needed
);
bit_cnt
++
;
bit_cnt
++
;
...
@@ -1179,7 +1179,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
...
@@ -1179,7 +1179,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
return
ret
;
return
ret
;
}
}
void
bitmap_write_all
(
struct
bitmap
*
bitmap
)
void
md_
bitmap_write_all
(
struct
bitmap
*
bitmap
)
{
{
/* We don't actually write all bitmap blocks here,
/* We don't actually write all bitmap blocks here,
* just flag them as needing to be written
* just flag them as needing to be written
...
@@ -1198,16 +1198,16 @@ void bitmap_write_all(struct bitmap *bitmap)
...
@@ -1198,16 +1198,16 @@ void bitmap_write_all(struct bitmap *bitmap)
bitmap
->
allclean
=
0
;
bitmap
->
allclean
=
0
;
}
}
static
void
bitmap_count_page
(
struct
bitmap_counts
*
bitmap
,
static
void
md_
bitmap_count_page
(
struct
bitmap_counts
*
bitmap
,
sector_t
offset
,
int
inc
)
sector_t
offset
,
int
inc
)
{
{
sector_t
chunk
=
offset
>>
bitmap
->
chunkshift
;
sector_t
chunk
=
offset
>>
bitmap
->
chunkshift
;
unsigned
long
page
=
chunk
>>
PAGE_COUNTER_SHIFT
;
unsigned
long
page
=
chunk
>>
PAGE_COUNTER_SHIFT
;
bitmap
->
bp
[
page
].
count
+=
inc
;
bitmap
->
bp
[
page
].
count
+=
inc
;
bitmap_checkfree
(
bitmap
,
page
);
md_
bitmap_checkfree
(
bitmap
,
page
);
}
}
static
void
bitmap_set_pending
(
struct
bitmap_counts
*
bitmap
,
sector_t
offset
)
static
void
md_
bitmap_set_pending
(
struct
bitmap_counts
*
bitmap
,
sector_t
offset
)
{
{
sector_t
chunk
=
offset
>>
bitmap
->
chunkshift
;
sector_t
chunk
=
offset
>>
bitmap
->
chunkshift
;
unsigned
long
page
=
chunk
>>
PAGE_COUNTER_SHIFT
;
unsigned
long
page
=
chunk
>>
PAGE_COUNTER_SHIFT
;
...
@@ -1217,7 +1217,7 @@ static void bitmap_set_pending(struct bitmap_counts *bitmap, sector_t offset)
...
@@ -1217,7 +1217,7 @@ static void bitmap_set_pending(struct bitmap_counts *bitmap, sector_t offset)
bp
->
pending
=
1
;
bp
->
pending
=
1
;
}
}
static
bitmap_counter_t
*
bitmap_get_counter
(
struct
bitmap_counts
*
bitmap
,
static
bitmap_counter_t
*
md_
bitmap_get_counter
(
struct
bitmap_counts
*
bitmap
,
sector_t
offset
,
sector_t
*
blocks
,
sector_t
offset
,
sector_t
*
blocks
,
int
create
);
int
create
);
...
@@ -1226,7 +1226,7 @@ static bitmap_counter_t *bitmap_get_counter(struct bitmap_counts *bitmap,
...
@@ -1226,7 +1226,7 @@ static bitmap_counter_t *bitmap_get_counter(struct bitmap_counts *bitmap,
* out to disk
* out to disk
*/
*/
void
bitmap_daemon_work
(
struct
mddev
*
mddev
)
void
md_
bitmap_daemon_work
(
struct
mddev
*
mddev
)
{
{
struct
bitmap
*
bitmap
;
struct
bitmap
*
bitmap
;
unsigned
long
j
;
unsigned
long
j
;
...
@@ -1301,10 +1301,8 @@ void bitmap_daemon_work(struct mddev *mddev)
...
@@ -1301,10 +1301,8 @@ void bitmap_daemon_work(struct mddev *mddev)
}
}
counts
->
bp
[
j
>>
PAGE_COUNTER_SHIFT
].
pending
=
0
;
counts
->
bp
[
j
>>
PAGE_COUNTER_SHIFT
].
pending
=
0
;
}
}
bmc
=
bitmap_get_counter
(
counts
,
block
,
&
blocks
,
0
);
bmc
=
md_bitmap_get_counter
(
counts
,
block
,
&
blocks
,
0
);
if
(
!
bmc
)
{
if
(
!
bmc
)
{
j
|=
PAGE_COUNTER_MASK
;
j
|=
PAGE_COUNTER_MASK
;
continue
;
continue
;
...
@@ -1312,17 +1310,17 @@ void bitmap_daemon_work(struct mddev *mddev)
...
@@ -1312,17 +1310,17 @@ void bitmap_daemon_work(struct mddev *mddev)
if
(
*
bmc
==
1
&&
!
bitmap
->
need_sync
)
{
if
(
*
bmc
==
1
&&
!
bitmap
->
need_sync
)
{
/* We can clear the bit */
/* We can clear the bit */
*
bmc
=
0
;
*
bmc
=
0
;
bitmap_count_page
(
counts
,
block
,
-
1
);
md_
bitmap_count_page
(
counts
,
block
,
-
1
);
bitmap_file_clear_bit
(
bitmap
,
block
);
md_
bitmap_file_clear_bit
(
bitmap
,
block
);
}
else
if
(
*
bmc
&&
*
bmc
<=
2
)
{
}
else
if
(
*
bmc
&&
*
bmc
<=
2
)
{
*
bmc
=
1
;
*
bmc
=
1
;
bitmap_set_pending
(
counts
,
block
);
md_
bitmap_set_pending
(
counts
,
block
);
bitmap
->
allclean
=
0
;
bitmap
->
allclean
=
0
;
}
}
}
}
spin_unlock_irq
(
&
counts
->
lock
);
spin_unlock_irq
(
&
counts
->
lock
);
bitmap_wait_writes
(
bitmap
);
md_
bitmap_wait_writes
(
bitmap
);
/* Now start writeout on any page in NEEDWRITE that isn't DIRTY.
/* Now start writeout on any page in NEEDWRITE that isn't DIRTY.
* DIRTY pages need to be written by bitmap_unplug so it can wait
* DIRTY pages need to be written by bitmap_unplug so it can wait
* for them.
* for them.
...
@@ -1352,7 +1350,7 @@ void bitmap_daemon_work(struct mddev *mddev)
...
@@ -1352,7 +1350,7 @@ void bitmap_daemon_work(struct mddev *mddev)
mutex_unlock
(
&
mddev
->
bitmap_info
.
mutex
);
mutex_unlock
(
&
mddev
->
bitmap_info
.
mutex
);
}
}
static
bitmap_counter_t
*
bitmap_get_counter
(
struct
bitmap_counts
*
bitmap
,
static
bitmap_counter_t
*
md_
bitmap_get_counter
(
struct
bitmap_counts
*
bitmap
,
sector_t
offset
,
sector_t
*
blocks
,
sector_t
offset
,
sector_t
*
blocks
,
int
create
)
int
create
)
__releases
(
bitmap
->
lock
)
__releases
(
bitmap
->
lock
)
...
@@ -1368,7 +1366,7 @@ __acquires(bitmap->lock)
...
@@ -1368,7 +1366,7 @@ __acquires(bitmap->lock)
sector_t
csize
;
sector_t
csize
;
int
err
;
int
err
;
err
=
bitmap_checkpage
(
bitmap
,
page
,
create
,
0
);
err
=
md_
bitmap_checkpage
(
bitmap
,
page
,
create
,
0
);
if
(
bitmap
->
bp
[
page
].
hijacked
||
if
(
bitmap
->
bp
[
page
].
hijacked
||
bitmap
->
bp
[
page
].
map
==
NULL
)
bitmap
->
bp
[
page
].
map
==
NULL
)
...
@@ -1394,7 +1392,7 @@ __acquires(bitmap->lock)
...
@@ -1394,7 +1392,7 @@ __acquires(bitmap->lock)
&
(
bitmap
->
bp
[
page
].
map
[
pageoff
]);
&
(
bitmap
->
bp
[
page
].
map
[
pageoff
]);
}
}
int
bitmap_startwrite
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
unsigned
long
sectors
,
int
behind
)
int
md_
bitmap_startwrite
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
unsigned
long
sectors
,
int
behind
)
{
{
if
(
!
bitmap
)
if
(
!
bitmap
)
return
0
;
return
0
;
...
@@ -1415,7 +1413,7 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
...
@@ -1415,7 +1413,7 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
bitmap_counter_t
*
bmc
;
bitmap_counter_t
*
bmc
;
spin_lock_irq
(
&
bitmap
->
counts
.
lock
);
spin_lock_irq
(
&
bitmap
->
counts
.
lock
);
bmc
=
bitmap_get_counter
(
&
bitmap
->
counts
,
offset
,
&
blocks
,
1
);
bmc
=
md_
bitmap_get_counter
(
&
bitmap
->
counts
,
offset
,
&
blocks
,
1
);
if
(
!
bmc
)
{
if
(
!
bmc
)
{
spin_unlock_irq
(
&
bitmap
->
counts
.
lock
);
spin_unlock_irq
(
&
bitmap
->
counts
.
lock
);
return
0
;
return
0
;
...
@@ -1437,8 +1435,8 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
...
@@ -1437,8 +1435,8 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
switch
(
*
bmc
)
{
switch
(
*
bmc
)
{
case
0
:
case
0
:
bitmap_file_set_bit
(
bitmap
,
offset
);
md_
bitmap_file_set_bit
(
bitmap
,
offset
);
bitmap_count_page
(
&
bitmap
->
counts
,
offset
,
1
);
md_
bitmap_count_page
(
&
bitmap
->
counts
,
offset
,
1
);
/* fall through */
/* fall through */
case
1
:
case
1
:
*
bmc
=
2
;
*
bmc
=
2
;
...
@@ -1456,10 +1454,10 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
...
@@ -1456,10 +1454,10 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
}
}
return
0
;
return
0
;
}
}
EXPORT_SYMBOL
(
bitmap_startwrite
);
EXPORT_SYMBOL
(
md_
bitmap_startwrite
);
void
bitmap_endwrite
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
unsigned
long
sectors
,
void
md_bitmap_endwrite
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
int
success
,
int
behind
)
unsigned
long
sectors
,
int
success
,
int
behind
)
{
{
if
(
!
bitmap
)
if
(
!
bitmap
)
return
;
return
;
...
@@ -1477,7 +1475,7 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
...
@@ -1477,7 +1475,7 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
bitmap_counter_t
*
bmc
;
bitmap_counter_t
*
bmc
;
spin_lock_irqsave
(
&
bitmap
->
counts
.
lock
,
flags
);
spin_lock_irqsave
(
&
bitmap
->
counts
.
lock
,
flags
);
bmc
=
bitmap_get_counter
(
&
bitmap
->
counts
,
offset
,
&
blocks
,
0
);
bmc
=
md_
bitmap_get_counter
(
&
bitmap
->
counts
,
offset
,
&
blocks
,
0
);
if
(
!
bmc
)
{
if
(
!
bmc
)
{
spin_unlock_irqrestore
(
&
bitmap
->
counts
.
lock
,
flags
);
spin_unlock_irqrestore
(
&
bitmap
->
counts
.
lock
,
flags
);
return
;
return
;
...
@@ -1498,7 +1496,7 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
...
@@ -1498,7 +1496,7 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
(
*
bmc
)
--
;
(
*
bmc
)
--
;
if
(
*
bmc
<=
2
)
{
if
(
*
bmc
<=
2
)
{
bitmap_set_pending
(
&
bitmap
->
counts
,
offset
);
md_
bitmap_set_pending
(
&
bitmap
->
counts
,
offset
);
bitmap
->
allclean
=
0
;
bitmap
->
allclean
=
0
;
}
}
spin_unlock_irqrestore
(
&
bitmap
->
counts
.
lock
,
flags
);
spin_unlock_irqrestore
(
&
bitmap
->
counts
.
lock
,
flags
);
...
@@ -1509,7 +1507,7 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
...
@@ -1509,7 +1507,7 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
sectors
=
0
;
sectors
=
0
;
}
}
}
}
EXPORT_SYMBOL
(
bitmap_endwrite
);
EXPORT_SYMBOL
(
md_
bitmap_endwrite
);
static
int
__bitmap_start_sync
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
sector_t
*
blocks
,
static
int
__bitmap_start_sync
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
sector_t
*
blocks
,
int
degraded
)
int
degraded
)
...
@@ -1521,7 +1519,7 @@ static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t
...
@@ -1521,7 +1519,7 @@ static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t
return
1
;
/* always resync if no bitmap */
return
1
;
/* always resync if no bitmap */
}
}
spin_lock_irq
(
&
bitmap
->
counts
.
lock
);
spin_lock_irq
(
&
bitmap
->
counts
.
lock
);
bmc
=
bitmap_get_counter
(
&
bitmap
->
counts
,
offset
,
blocks
,
0
);
bmc
=
md_
bitmap_get_counter
(
&
bitmap
->
counts
,
offset
,
blocks
,
0
);
rv
=
0
;
rv
=
0
;
if
(
bmc
)
{
if
(
bmc
)
{
/* locked */
/* locked */
...
@@ -1539,7 +1537,7 @@ static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t
...
@@ -1539,7 +1537,7 @@ static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t
return
rv
;
return
rv
;
}
}
int
bitmap_start_sync
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
sector_t
*
blocks
,
int
md_
bitmap_start_sync
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
sector_t
*
blocks
,
int
degraded
)
int
degraded
)
{
{
/* bitmap_start_sync must always report on multiples of whole
/* bitmap_start_sync must always report on multiples of whole
...
@@ -1561,9 +1559,9 @@ int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks,
...
@@ -1561,9 +1559,9 @@ int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks,
}
}
return
rv
;
return
rv
;
}
}
EXPORT_SYMBOL
(
bitmap_start_sync
);
EXPORT_SYMBOL
(
md_
bitmap_start_sync
);
void
bitmap_end_sync
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
sector_t
*
blocks
,
int
aborted
)
void
md_
bitmap_end_sync
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
sector_t
*
blocks
,
int
aborted
)
{
{
bitmap_counter_t
*
bmc
;
bitmap_counter_t
*
bmc
;
unsigned
long
flags
;
unsigned
long
flags
;
...
@@ -1573,7 +1571,7 @@ void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, i
...
@@ -1573,7 +1571,7 @@ void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, i
return
;
return
;
}
}
spin_lock_irqsave
(
&
bitmap
->
counts
.
lock
,
flags
);
spin_lock_irqsave
(
&
bitmap
->
counts
.
lock
,
flags
);
bmc
=
bitmap_get_counter
(
&
bitmap
->
counts
,
offset
,
blocks
,
0
);
bmc
=
md_
bitmap_get_counter
(
&
bitmap
->
counts
,
offset
,
blocks
,
0
);
if
(
bmc
==
NULL
)
if
(
bmc
==
NULL
)
goto
unlock
;
goto
unlock
;
/* locked */
/* locked */
...
@@ -1584,7 +1582,7 @@ void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, i
...
@@ -1584,7 +1582,7 @@ void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, i
*
bmc
|=
NEEDED_MASK
;
*
bmc
|=
NEEDED_MASK
;
else
{
else
{
if
(
*
bmc
<=
2
)
{
if
(
*
bmc
<=
2
)
{
bitmap_set_pending
(
&
bitmap
->
counts
,
offset
);
md_
bitmap_set_pending
(
&
bitmap
->
counts
,
offset
);
bitmap
->
allclean
=
0
;
bitmap
->
allclean
=
0
;
}
}
}
}
...
@@ -1592,9 +1590,9 @@ void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, i
...
@@ -1592,9 +1590,9 @@ void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, i
unlock:
unlock:
spin_unlock_irqrestore
(
&
bitmap
->
counts
.
lock
,
flags
);
spin_unlock_irqrestore
(
&
bitmap
->
counts
.
lock
,
flags
);
}
}
EXPORT_SYMBOL
(
bitmap_end_sync
);
EXPORT_SYMBOL
(
md_
bitmap_end_sync
);
void
bitmap_close_sync
(
struct
bitmap
*
bitmap
)
void
md_
bitmap_close_sync
(
struct
bitmap
*
bitmap
)
{
{
/* Sync has finished, and any bitmap chunks that weren't synced
/* Sync has finished, and any bitmap chunks that weren't synced
* properly have been aborted. It remains to us to clear the
* properly have been aborted. It remains to us to clear the
...
@@ -1605,13 +1603,13 @@ void bitmap_close_sync(struct bitmap *bitmap)
...
@@ -1605,13 +1603,13 @@ void bitmap_close_sync(struct bitmap *bitmap)
if
(
!
bitmap
)
if
(
!
bitmap
)
return
;
return
;
while
(
sector
<
bitmap
->
mddev
->
resync_max_sectors
)
{
while
(
sector
<
bitmap
->
mddev
->
resync_max_sectors
)
{
bitmap_end_sync
(
bitmap
,
sector
,
&
blocks
,
0
);
md_
bitmap_end_sync
(
bitmap
,
sector
,
&
blocks
,
0
);
sector
+=
blocks
;
sector
+=
blocks
;
}
}
}
}
EXPORT_SYMBOL
(
bitmap_close_sync
);
EXPORT_SYMBOL
(
md_
bitmap_close_sync
);
void
bitmap_cond_end_sync
(
struct
bitmap
*
bitmap
,
sector_t
sector
,
bool
force
)
void
md_
bitmap_cond_end_sync
(
struct
bitmap
*
bitmap
,
sector_t
sector
,
bool
force
)
{
{
sector_t
s
=
0
;
sector_t
s
=
0
;
sector_t
blocks
;
sector_t
blocks
;
...
@@ -1633,15 +1631,15 @@ void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force)
...
@@ -1633,15 +1631,15 @@ void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force)
sector
&=
~
((
1ULL
<<
bitmap
->
counts
.
chunkshift
)
-
1
);
sector
&=
~
((
1ULL
<<
bitmap
->
counts
.
chunkshift
)
-
1
);
s
=
0
;
s
=
0
;
while
(
s
<
sector
&&
s
<
bitmap
->
mddev
->
resync_max_sectors
)
{
while
(
s
<
sector
&&
s
<
bitmap
->
mddev
->
resync_max_sectors
)
{
bitmap_end_sync
(
bitmap
,
s
,
&
blocks
,
0
);
md_
bitmap_end_sync
(
bitmap
,
s
,
&
blocks
,
0
);
s
+=
blocks
;
s
+=
blocks
;
}
}
bitmap
->
last_end_sync
=
jiffies
;
bitmap
->
last_end_sync
=
jiffies
;
sysfs_notify
(
&
bitmap
->
mddev
->
kobj
,
NULL
,
"sync_completed"
);
sysfs_notify
(
&
bitmap
->
mddev
->
kobj
,
NULL
,
"sync_completed"
);
}
}
EXPORT_SYMBOL
(
bitmap_cond_end_sync
);
EXPORT_SYMBOL
(
md_
bitmap_cond_end_sync
);
void
bitmap_sync_with_cluster
(
struct
mddev
*
mddev
,
void
md_
bitmap_sync_with_cluster
(
struct
mddev
*
mddev
,
sector_t
old_lo
,
sector_t
old_hi
,
sector_t
old_lo
,
sector_t
old_hi
,
sector_t
new_lo
,
sector_t
new_hi
)
sector_t
new_lo
,
sector_t
new_hi
)
{
{
...
@@ -1649,20 +1647,20 @@ void bitmap_sync_with_cluster(struct mddev *mddev,
...
@@ -1649,20 +1647,20 @@ void bitmap_sync_with_cluster(struct mddev *mddev,
sector_t
sector
,
blocks
=
0
;
sector_t
sector
,
blocks
=
0
;
for
(
sector
=
old_lo
;
sector
<
new_lo
;
)
{
for
(
sector
=
old_lo
;
sector
<
new_lo
;
)
{
bitmap_end_sync
(
bitmap
,
sector
,
&
blocks
,
0
);
md_
bitmap_end_sync
(
bitmap
,
sector
,
&
blocks
,
0
);
sector
+=
blocks
;
sector
+=
blocks
;
}
}
WARN
((
blocks
>
new_lo
)
&&
old_lo
,
"alignment is not correct for lo
\n
"
);
WARN
((
blocks
>
new_lo
)
&&
old_lo
,
"alignment is not correct for lo
\n
"
);
for
(
sector
=
old_hi
;
sector
<
new_hi
;
)
{
for
(
sector
=
old_hi
;
sector
<
new_hi
;
)
{
bitmap_start_sync
(
bitmap
,
sector
,
&
blocks
,
0
);
md_
bitmap_start_sync
(
bitmap
,
sector
,
&
blocks
,
0
);
sector
+=
blocks
;
sector
+=
blocks
;
}
}
WARN
((
blocks
>
new_hi
)
&&
old_hi
,
"alignment is not correct for hi
\n
"
);
WARN
((
blocks
>
new_hi
)
&&
old_hi
,
"alignment is not correct for hi
\n
"
);
}
}
EXPORT_SYMBOL
(
bitmap_sync_with_cluster
);
EXPORT_SYMBOL
(
md_
bitmap_sync_with_cluster
);
static
void
bitmap_set_memory_bits
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
int
needed
)
static
void
md_
bitmap_set_memory_bits
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
int
needed
)
{
{
/* For each chunk covered by any of these sectors, set the
/* For each chunk covered by any of these sectors, set the
* counter to 2 and possibly set resync_needed. They should all
* counter to 2 and possibly set resync_needed. They should all
...
@@ -1672,15 +1670,15 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n
...
@@ -1672,15 +1670,15 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n
sector_t
secs
;
sector_t
secs
;
bitmap_counter_t
*
bmc
;
bitmap_counter_t
*
bmc
;
spin_lock_irq
(
&
bitmap
->
counts
.
lock
);
spin_lock_irq
(
&
bitmap
->
counts
.
lock
);
bmc
=
bitmap_get_counter
(
&
bitmap
->
counts
,
offset
,
&
secs
,
1
);
bmc
=
md_
bitmap_get_counter
(
&
bitmap
->
counts
,
offset
,
&
secs
,
1
);
if
(
!
bmc
)
{
if
(
!
bmc
)
{
spin_unlock_irq
(
&
bitmap
->
counts
.
lock
);
spin_unlock_irq
(
&
bitmap
->
counts
.
lock
);
return
;
return
;
}
}
if
(
!*
bmc
)
{
if
(
!*
bmc
)
{
*
bmc
=
2
;
*
bmc
=
2
;
bitmap_count_page
(
&
bitmap
->
counts
,
offset
,
1
);
md_
bitmap_count_page
(
&
bitmap
->
counts
,
offset
,
1
);
bitmap_set_pending
(
&
bitmap
->
counts
,
offset
);
md_
bitmap_set_pending
(
&
bitmap
->
counts
,
offset
);
bitmap
->
allclean
=
0
;
bitmap
->
allclean
=
0
;
}
}
if
(
needed
)
if
(
needed
)
...
@@ -1689,14 +1687,14 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n
...
@@ -1689,14 +1687,14 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n
}
}
/* dirty the memory and file bits for bitmap chunks "s" to "e" */
/* dirty the memory and file bits for bitmap chunks "s" to "e" */
void
bitmap_dirty_bits
(
struct
bitmap
*
bitmap
,
unsigned
long
s
,
unsigned
long
e
)
void
md_
bitmap_dirty_bits
(
struct
bitmap
*
bitmap
,
unsigned
long
s
,
unsigned
long
e
)
{
{
unsigned
long
chunk
;
unsigned
long
chunk
;
for
(
chunk
=
s
;
chunk
<=
e
;
chunk
++
)
{
for
(
chunk
=
s
;
chunk
<=
e
;
chunk
++
)
{
sector_t
sec
=
(
sector_t
)
chunk
<<
bitmap
->
counts
.
chunkshift
;
sector_t
sec
=
(
sector_t
)
chunk
<<
bitmap
->
counts
.
chunkshift
;
bitmap_set_memory_bits
(
bitmap
,
sec
,
1
);
md_
bitmap_set_memory_bits
(
bitmap
,
sec
,
1
);
bitmap_file_set_bit
(
bitmap
,
sec
);
md_
bitmap_file_set_bit
(
bitmap
,
sec
);
if
(
sec
<
bitmap
->
mddev
->
recovery_cp
)
if
(
sec
<
bitmap
->
mddev
->
recovery_cp
)
/* We are asserting that the array is dirty,
/* We are asserting that the array is dirty,
* so move the recovery_cp address back so
* so move the recovery_cp address back so
...
@@ -1709,7 +1707,7 @@ void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e)
...
@@ -1709,7 +1707,7 @@ void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e)
/*
/*
* flush out any pending updates
* flush out any pending updates
*/
*/
void
bitmap_flush
(
struct
mddev
*
mddev
)
void
md_
bitmap_flush
(
struct
mddev
*
mddev
)
{
{
struct
bitmap
*
bitmap
=
mddev
->
bitmap
;
struct
bitmap
*
bitmap
=
mddev
->
bitmap
;
long
sleep
;
long
sleep
;
...
@@ -1722,18 +1720,18 @@ void bitmap_flush(struct mddev *mddev)
...
@@ -1722,18 +1720,18 @@ void bitmap_flush(struct mddev *mddev)
*/
*/
sleep
=
mddev
->
bitmap_info
.
daemon_sleep
*
2
;
sleep
=
mddev
->
bitmap_info
.
daemon_sleep
*
2
;
bitmap
->
daemon_lastrun
-=
sleep
;
bitmap
->
daemon_lastrun
-=
sleep
;
bitmap_daemon_work
(
mddev
);
md_
bitmap_daemon_work
(
mddev
);
bitmap
->
daemon_lastrun
-=
sleep
;
bitmap
->
daemon_lastrun
-=
sleep
;
bitmap_daemon_work
(
mddev
);
md_
bitmap_daemon_work
(
mddev
);
bitmap
->
daemon_lastrun
-=
sleep
;
bitmap
->
daemon_lastrun
-=
sleep
;
bitmap_daemon_work
(
mddev
);
md_
bitmap_daemon_work
(
mddev
);
bitmap_update_sb
(
bitmap
);
md_
bitmap_update_sb
(
bitmap
);
}
}
/*
/*
* free memory that was allocated
* free memory that was allocated
*/
*/
void
bitmap_free
(
struct
bitmap
*
bitmap
)
void
md_
bitmap_free
(
struct
bitmap
*
bitmap
)
{
{
unsigned
long
k
,
pages
;
unsigned
long
k
,
pages
;
struct
bitmap_page
*
bp
;
struct
bitmap_page
*
bp
;
...
@@ -1753,7 +1751,7 @@ void bitmap_free(struct bitmap *bitmap)
...
@@ -1753,7 +1751,7 @@ void bitmap_free(struct bitmap *bitmap)
atomic_read
(
&
bitmap
->
pending_writes
)
==
0
);
atomic_read
(
&
bitmap
->
pending_writes
)
==
0
);
/* release the bitmap file */
/* release the bitmap file */
bitmap_file_unmap
(
&
bitmap
->
storage
);
md_
bitmap_file_unmap
(
&
bitmap
->
storage
);
bp
=
bitmap
->
counts
.
bp
;
bp
=
bitmap
->
counts
.
bp
;
pages
=
bitmap
->
counts
.
pages
;
pages
=
bitmap
->
counts
.
pages
;
...
@@ -1767,9 +1765,9 @@ void bitmap_free(struct bitmap *bitmap)
...
@@ -1767,9 +1765,9 @@ void bitmap_free(struct bitmap *bitmap)
kfree
(
bp
);
kfree
(
bp
);
kfree
(
bitmap
);
kfree
(
bitmap
);
}
}
EXPORT_SYMBOL
(
bitmap_free
);
EXPORT_SYMBOL
(
md_
bitmap_free
);
void
bitmap_wait_behind_writes
(
struct
mddev
*
mddev
)
void
md_
bitmap_wait_behind_writes
(
struct
mddev
*
mddev
)
{
{
struct
bitmap
*
bitmap
=
mddev
->
bitmap
;
struct
bitmap
*
bitmap
=
mddev
->
bitmap
;
...
@@ -1783,14 +1781,14 @@ void bitmap_wait_behind_writes(struct mddev *mddev)
...
@@ -1783,14 +1781,14 @@ void bitmap_wait_behind_writes(struct mddev *mddev)
}
}
}
}
void
bitmap_destroy
(
struct
mddev
*
mddev
)
void
md_
bitmap_destroy
(
struct
mddev
*
mddev
)
{
{
struct
bitmap
*
bitmap
=
mddev
->
bitmap
;
struct
bitmap
*
bitmap
=
mddev
->
bitmap
;
if
(
!
bitmap
)
/* there was no bitmap */
if
(
!
bitmap
)
/* there was no bitmap */
return
;
return
;
bitmap_wait_behind_writes
(
mddev
);
md_
bitmap_wait_behind_writes
(
mddev
);
mutex_lock
(
&
mddev
->
bitmap_info
.
mutex
);
mutex_lock
(
&
mddev
->
bitmap_info
.
mutex
);
spin_lock
(
&
mddev
->
lock
);
spin_lock
(
&
mddev
->
lock
);
...
@@ -1800,7 +1798,7 @@ void bitmap_destroy(struct mddev *mddev)
...
@@ -1800,7 +1798,7 @@ void bitmap_destroy(struct mddev *mddev)
if
(
mddev
->
thread
)
if
(
mddev
->
thread
)
mddev
->
thread
->
timeout
=
MAX_SCHEDULE_TIMEOUT
;
mddev
->
thread
->
timeout
=
MAX_SCHEDULE_TIMEOUT
;
bitmap_free
(
bitmap
);
md_
bitmap_free
(
bitmap
);
}
}
/*
/*
...
@@ -1808,7 +1806,7 @@ void bitmap_destroy(struct mddev *mddev)
...
@@ -1808,7 +1806,7 @@ void bitmap_destroy(struct mddev *mddev)
* if this returns an error, bitmap_destroy must be called to do clean up
* if this returns an error, bitmap_destroy must be called to do clean up
* once mddev->bitmap is set
* once mddev->bitmap is set
*/
*/
struct
bitmap
*
bitmap_create
(
struct
mddev
*
mddev
,
int
slot
)
struct
bitmap
*
md_
bitmap_create
(
struct
mddev
*
mddev
,
int
slot
)
{
{
struct
bitmap
*
bitmap
;
struct
bitmap
*
bitmap
;
sector_t
blocks
=
mddev
->
resync_max_sectors
;
sector_t
blocks
=
mddev
->
resync_max_sectors
;
...
@@ -1863,9 +1861,9 @@ struct bitmap *bitmap_create(struct mddev *mddev, int slot)
...
@@ -1863,9 +1861,9 @@ struct bitmap *bitmap_create(struct mddev *mddev, int slot)
* instructing us to create a new on-disk bitmap instance.
* instructing us to create a new on-disk bitmap instance.
*/
*/
if
(
test_and_clear_bit
(
MD_ARRAY_FIRST_USE
,
&
mddev
->
flags
))
if
(
test_and_clear_bit
(
MD_ARRAY_FIRST_USE
,
&
mddev
->
flags
))
err
=
bitmap_new_disk_sb
(
bitmap
);
err
=
md_
bitmap_new_disk_sb
(
bitmap
);
else
else
err
=
bitmap_read_sb
(
bitmap
);
err
=
md_
bitmap_read_sb
(
bitmap
);
}
else
{
}
else
{
err
=
0
;
err
=
0
;
if
(
mddev
->
bitmap_info
.
chunksize
==
0
||
if
(
mddev
->
bitmap_info
.
chunksize
==
0
||
...
@@ -1878,7 +1876,7 @@ struct bitmap *bitmap_create(struct mddev *mddev, int slot)
...
@@ -1878,7 +1876,7 @@ struct bitmap *bitmap_create(struct mddev *mddev, int slot)
goto
error
;
goto
error
;
bitmap
->
daemon_lastrun
=
jiffies
;
bitmap
->
daemon_lastrun
=
jiffies
;
err
=
bitmap_resize
(
bitmap
,
blocks
,
mddev
->
bitmap_info
.
chunksize
,
1
);
err
=
md_
bitmap_resize
(
bitmap
,
blocks
,
mddev
->
bitmap_info
.
chunksize
,
1
);
if
(
err
)
if
(
err
)
goto
error
;
goto
error
;
...
@@ -1891,11 +1889,11 @@ struct bitmap *bitmap_create(struct mddev *mddev, int slot)
...
@@ -1891,11 +1889,11 @@ struct bitmap *bitmap_create(struct mddev *mddev, int slot)
return
bitmap
;
return
bitmap
;
error:
error:
bitmap_free
(
bitmap
);
md_
bitmap_free
(
bitmap
);
return
ERR_PTR
(
err
);
return
ERR_PTR
(
err
);
}
}
int
bitmap_load
(
struct
mddev
*
mddev
)
int
md_
bitmap_load
(
struct
mddev
*
mddev
)
{
{
int
err
=
0
;
int
err
=
0
;
sector_t
start
=
0
;
sector_t
start
=
0
;
...
@@ -1915,10 +1913,10 @@ int bitmap_load(struct mddev *mddev)
...
@@ -1915,10 +1913,10 @@ int bitmap_load(struct mddev *mddev)
*/
*/
while
(
sector
<
mddev
->
resync_max_sectors
)
{
while
(
sector
<
mddev
->
resync_max_sectors
)
{
sector_t
blocks
;
sector_t
blocks
;
bitmap_start_sync
(
bitmap
,
sector
,
&
blocks
,
0
);
md_
bitmap_start_sync
(
bitmap
,
sector
,
&
blocks
,
0
);
sector
+=
blocks
;
sector
+=
blocks
;
}
}
bitmap_close_sync
(
bitmap
);
md_
bitmap_close_sync
(
bitmap
);
if
(
mddev
->
degraded
==
0
if
(
mddev
->
degraded
==
0
||
bitmap
->
events_cleared
==
mddev
->
events
)
||
bitmap
->
events_cleared
==
mddev
->
events
)
...
@@ -1927,7 +1925,7 @@ int bitmap_load(struct mddev *mddev)
...
@@ -1927,7 +1925,7 @@ int bitmap_load(struct mddev *mddev)
start
=
mddev
->
recovery_cp
;
start
=
mddev
->
recovery_cp
;
mutex_lock
(
&
mddev
->
bitmap_info
.
mutex
);
mutex_lock
(
&
mddev
->
bitmap_info
.
mutex
);
err
=
bitmap_init_from_disk
(
bitmap
,
start
);
err
=
md_
bitmap_init_from_disk
(
bitmap
,
start
);
mutex_unlock
(
&
mddev
->
bitmap_info
.
mutex
);
mutex_unlock
(
&
mddev
->
bitmap_info
.
mutex
);
if
(
err
)
if
(
err
)
...
@@ -1940,29 +1938,29 @@ int bitmap_load(struct mddev *mddev)
...
@@ -1940,29 +1938,29 @@ int bitmap_load(struct mddev *mddev)
mddev
->
thread
->
timeout
=
mddev
->
bitmap_info
.
daemon_sleep
;
mddev
->
thread
->
timeout
=
mddev
->
bitmap_info
.
daemon_sleep
;
md_wakeup_thread
(
mddev
->
thread
);
md_wakeup_thread
(
mddev
->
thread
);
bitmap_update_sb
(
bitmap
);
md_
bitmap_update_sb
(
bitmap
);
if
(
test_bit
(
BITMAP_WRITE_ERROR
,
&
bitmap
->
flags
))
if
(
test_bit
(
BITMAP_WRITE_ERROR
,
&
bitmap
->
flags
))
err
=
-
EIO
;
err
=
-
EIO
;
out:
out:
return
err
;
return
err
;
}
}
EXPORT_SYMBOL_GPL
(
bitmap_load
);
EXPORT_SYMBOL_GPL
(
md_
bitmap_load
);
struct
bitmap
*
get_bitmap_from_slot
(
struct
mddev
*
mddev
,
int
slot
)
struct
bitmap
*
get_bitmap_from_slot
(
struct
mddev
*
mddev
,
int
slot
)
{
{
int
rv
=
0
;
int
rv
=
0
;
struct
bitmap
*
bitmap
;
struct
bitmap
*
bitmap
;
bitmap
=
bitmap_create
(
mddev
,
slot
);
bitmap
=
md_
bitmap_create
(
mddev
,
slot
);
if
(
IS_ERR
(
bitmap
))
{
if
(
IS_ERR
(
bitmap
))
{
rv
=
PTR_ERR
(
bitmap
);
rv
=
PTR_ERR
(
bitmap
);
return
ERR_PTR
(
rv
);
return
ERR_PTR
(
rv
);
}
}
rv
=
bitmap_init_from_disk
(
bitmap
,
0
);
rv
=
md_
bitmap_init_from_disk
(
bitmap
,
0
);
if
(
rv
)
{
if
(
rv
)
{
bitmap_free
(
bitmap
);
md_
bitmap_free
(
bitmap
);
return
ERR_PTR
(
rv
);
return
ERR_PTR
(
rv
);
}
}
...
@@ -1973,7 +1971,7 @@ EXPORT_SYMBOL(get_bitmap_from_slot);
...
@@ -1973,7 +1971,7 @@ EXPORT_SYMBOL(get_bitmap_from_slot);
/* Loads the bitmap associated with slot and copies the resync information
/* Loads the bitmap associated with slot and copies the resync information
* to our bitmap
* to our bitmap
*/
*/
int
bitmap_copy_from_slot
(
struct
mddev
*
mddev
,
int
slot
,
int
md_
bitmap_copy_from_slot
(
struct
mddev
*
mddev
,
int
slot
,
sector_t
*
low
,
sector_t
*
high
,
bool
clear_bits
)
sector_t
*
low
,
sector_t
*
high
,
bool
clear_bits
)
{
{
int
rv
=
0
,
i
,
j
;
int
rv
=
0
,
i
,
j
;
...
@@ -1990,35 +1988,35 @@ int bitmap_copy_from_slot(struct mddev *mddev, int slot,
...
@@ -1990,35 +1988,35 @@ int bitmap_copy_from_slot(struct mddev *mddev, int slot,
counts
=
&
bitmap
->
counts
;
counts
=
&
bitmap
->
counts
;
for
(
j
=
0
;
j
<
counts
->
chunks
;
j
++
)
{
for
(
j
=
0
;
j
<
counts
->
chunks
;
j
++
)
{
block
=
(
sector_t
)
j
<<
counts
->
chunkshift
;
block
=
(
sector_t
)
j
<<
counts
->
chunkshift
;
if
(
bitmap_file_test_bit
(
bitmap
,
block
))
{
if
(
md_
bitmap_file_test_bit
(
bitmap
,
block
))
{
if
(
!
lo
)
if
(
!
lo
)
lo
=
block
;
lo
=
block
;
hi
=
block
;
hi
=
block
;
bitmap_file_clear_bit
(
bitmap
,
block
);
md_
bitmap_file_clear_bit
(
bitmap
,
block
);
bitmap_set_memory_bits
(
mddev
->
bitmap
,
block
,
1
);
md_
bitmap_set_memory_bits
(
mddev
->
bitmap
,
block
,
1
);
bitmap_file_set_bit
(
mddev
->
bitmap
,
block
);
md_
bitmap_file_set_bit
(
mddev
->
bitmap
,
block
);
}
}
}
}
if
(
clear_bits
)
{
if
(
clear_bits
)
{
bitmap_update_sb
(
bitmap
);
md_
bitmap_update_sb
(
bitmap
);
/* BITMAP_PAGE_PENDING is set, but bitmap_unplug needs
/* BITMAP_PAGE_PENDING is set, but bitmap_unplug needs
* BITMAP_PAGE_DIRTY or _NEEDWRITE to write ... */
* BITMAP_PAGE_DIRTY or _NEEDWRITE to write ... */
for
(
i
=
0
;
i
<
bitmap
->
storage
.
file_pages
;
i
++
)
for
(
i
=
0
;
i
<
bitmap
->
storage
.
file_pages
;
i
++
)
if
(
test_page_attr
(
bitmap
,
i
,
BITMAP_PAGE_PENDING
))
if
(
test_page_attr
(
bitmap
,
i
,
BITMAP_PAGE_PENDING
))
set_page_attr
(
bitmap
,
i
,
BITMAP_PAGE_NEEDWRITE
);
set_page_attr
(
bitmap
,
i
,
BITMAP_PAGE_NEEDWRITE
);
bitmap_unplug
(
bitmap
);
md_
bitmap_unplug
(
bitmap
);
}
}
bitmap_unplug
(
mddev
->
bitmap
);
md_
bitmap_unplug
(
mddev
->
bitmap
);
*
low
=
lo
;
*
low
=
lo
;
*
high
=
hi
;
*
high
=
hi
;
return
rv
;
return
rv
;
}
}
EXPORT_SYMBOL_GPL
(
bitmap_copy_from_slot
);
EXPORT_SYMBOL_GPL
(
md_
bitmap_copy_from_slot
);
void
bitmap_status
(
struct
seq_file
*
seq
,
struct
bitmap
*
bitmap
)
void
md_
bitmap_status
(
struct
seq_file
*
seq
,
struct
bitmap
*
bitmap
)
{
{
unsigned
long
chunk_kb
;
unsigned
long
chunk_kb
;
struct
bitmap_counts
*
counts
;
struct
bitmap_counts
*
counts
;
...
@@ -2045,7 +2043,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
...
@@ -2045,7 +2043,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
seq_printf
(
seq
,
"
\n
"
);
seq_printf
(
seq
,
"
\n
"
);
}
}
int
bitmap_resize
(
struct
bitmap
*
bitmap
,
sector_t
blocks
,
int
md_
bitmap_resize
(
struct
bitmap
*
bitmap
,
sector_t
blocks
,
int
chunksize
,
int
init
)
int
chunksize
,
int
init
)
{
{
/* If chunk_size is 0, choose an appropriate chunk size.
/* If chunk_size is 0, choose an appropriate chunk size.
...
@@ -2106,12 +2104,12 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
...
@@ -2106,12 +2104,12 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
chunks
=
DIV_ROUND_UP_SECTOR_T
(
blocks
,
1
<<
chunkshift
);
chunks
=
DIV_ROUND_UP_SECTOR_T
(
blocks
,
1
<<
chunkshift
);
memset
(
&
store
,
0
,
sizeof
(
store
));
memset
(
&
store
,
0
,
sizeof
(
store
));
if
(
bitmap
->
mddev
->
bitmap_info
.
offset
||
bitmap
->
mddev
->
bitmap_info
.
file
)
if
(
bitmap
->
mddev
->
bitmap_info
.
offset
||
bitmap
->
mddev
->
bitmap_info
.
file
)
ret
=
bitmap_storage_alloc
(
&
store
,
chunks
,
ret
=
md_
bitmap_storage_alloc
(
&
store
,
chunks
,
!
bitmap
->
mddev
->
bitmap_info
.
external
,
!
bitmap
->
mddev
->
bitmap_info
.
external
,
mddev_is_clustered
(
bitmap
->
mddev
)
mddev_is_clustered
(
bitmap
->
mddev
)
?
bitmap
->
cluster_slot
:
0
);
?
bitmap
->
cluster_slot
:
0
);
if
(
ret
)
{
if
(
ret
)
{
bitmap_file_unmap
(
&
store
);
md_
bitmap_file_unmap
(
&
store
);
goto
err
;
goto
err
;
}
}
...
@@ -2120,7 +2118,7 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
...
@@ -2120,7 +2118,7 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
new_bp
=
kzalloc
(
pages
*
sizeof
(
*
new_bp
),
GFP_KERNEL
);
new_bp
=
kzalloc
(
pages
*
sizeof
(
*
new_bp
),
GFP_KERNEL
);
ret
=
-
ENOMEM
;
ret
=
-
ENOMEM
;
if
(
!
new_bp
)
{
if
(
!
new_bp
)
{
bitmap_file_unmap
(
&
store
);
md_
bitmap_file_unmap
(
&
store
);
goto
err
;
goto
err
;
}
}
...
@@ -2134,7 +2132,7 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
...
@@ -2134,7 +2132,7 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
memcpy
(
page_address
(
store
.
sb_page
),
memcpy
(
page_address
(
store
.
sb_page
),
page_address
(
bitmap
->
storage
.
sb_page
),
page_address
(
bitmap
->
storage
.
sb_page
),
sizeof
(
bitmap_super_t
));
sizeof
(
bitmap_super_t
));
bitmap_file_unmap
(
&
bitmap
->
storage
);
md_
bitmap_file_unmap
(
&
bitmap
->
storage
);
bitmap
->
storage
=
store
;
bitmap
->
storage
=
store
;
old_counts
=
bitmap
->
counts
;
old_counts
=
bitmap
->
counts
;
...
@@ -2154,7 +2152,7 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
...
@@ -2154,7 +2152,7 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
if
(
mddev_is_clustered
(
bitmap
->
mddev
))
{
if
(
mddev_is_clustered
(
bitmap
->
mddev
))
{
unsigned
long
page
;
unsigned
long
page
;
for
(
page
=
0
;
page
<
pages
;
page
++
)
{
for
(
page
=
0
;
page
<
pages
;
page
++
)
{
ret
=
bitmap_checkpage
(
&
bitmap
->
counts
,
page
,
1
,
1
);
ret
=
md_
bitmap_checkpage
(
&
bitmap
->
counts
,
page
,
1
,
1
);
if
(
ret
)
{
if
(
ret
)
{
unsigned
long
k
;
unsigned
long
k
;
...
@@ -2184,27 +2182,23 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
...
@@ -2184,27 +2182,23 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
bitmap_counter_t
*
bmc_old
,
*
bmc_new
;
bitmap_counter_t
*
bmc_old
,
*
bmc_new
;
int
set
;
int
set
;
bmc_old
=
bitmap_get_counter
(
&
old_counts
,
block
,
bmc_old
=
md_bitmap_get_counter
(
&
old_counts
,
block
,
&
old_blocks
,
0
);
&
old_blocks
,
0
);
set
=
bmc_old
&&
NEEDED
(
*
bmc_old
);
set
=
bmc_old
&&
NEEDED
(
*
bmc_old
);
if
(
set
)
{
if
(
set
)
{
bmc_new
=
bitmap_get_counter
(
&
bitmap
->
counts
,
block
,
bmc_new
=
md_bitmap_get_counter
(
&
bitmap
->
counts
,
block
,
&
new_blocks
,
1
);
&
new_blocks
,
1
);
if
(
*
bmc_new
==
0
)
{
if
(
*
bmc_new
==
0
)
{
/* need to set on-disk bits too. */
/* need to set on-disk bits too. */
sector_t
end
=
block
+
new_blocks
;
sector_t
end
=
block
+
new_blocks
;
sector_t
start
=
block
>>
chunkshift
;
sector_t
start
=
block
>>
chunkshift
;
start
<<=
chunkshift
;
start
<<=
chunkshift
;
while
(
start
<
end
)
{
while
(
start
<
end
)
{
bitmap_file_set_bit
(
bitmap
,
block
);
md_
bitmap_file_set_bit
(
bitmap
,
block
);
start
+=
1
<<
chunkshift
;
start
+=
1
<<
chunkshift
;
}
}
*
bmc_new
=
2
;
*
bmc_new
=
2
;
bitmap_count_page
(
&
bitmap
->
counts
,
md_bitmap_count_page
(
&
bitmap
->
counts
,
block
,
1
);
block
,
1
);
md_bitmap_set_pending
(
&
bitmap
->
counts
,
block
);
bitmap_set_pending
(
&
bitmap
->
counts
,
block
);
}
}
*
bmc_new
|=
NEEDED_MASK
;
*
bmc_new
|=
NEEDED_MASK
;
if
(
new_blocks
<
old_blocks
)
if
(
new_blocks
<
old_blocks
)
...
@@ -2225,18 +2219,15 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
...
@@ -2225,18 +2219,15 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
int
i
;
int
i
;
while
(
block
<
(
chunks
<<
chunkshift
))
{
while
(
block
<
(
chunks
<<
chunkshift
))
{
bitmap_counter_t
*
bmc
;
bitmap_counter_t
*
bmc
;
bmc
=
bitmap_get_counter
(
&
bitmap
->
counts
,
block
,
bmc
=
md_bitmap_get_counter
(
&
bitmap
->
counts
,
block
,
&
new_blocks
,
1
);
&
new_blocks
,
1
);
if
(
bmc
)
{
if
(
bmc
)
{
/* new space. It needs to be resynced, so
/* new space. It needs to be resynced, so
* we set NEEDED_MASK.
* we set NEEDED_MASK.
*/
*/
if
(
*
bmc
==
0
)
{
if
(
*
bmc
==
0
)
{
*
bmc
=
NEEDED_MASK
|
2
;
*
bmc
=
NEEDED_MASK
|
2
;
bitmap_count_page
(
&
bitmap
->
counts
,
md_bitmap_count_page
(
&
bitmap
->
counts
,
block
,
1
);
block
,
1
);
md_bitmap_set_pending
(
&
bitmap
->
counts
,
block
);
bitmap_set_pending
(
&
bitmap
->
counts
,
block
);
}
}
}
}
block
+=
new_blocks
;
block
+=
new_blocks
;
...
@@ -2247,14 +2238,14 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
...
@@ -2247,14 +2238,14 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
spin_unlock_irq
(
&
bitmap
->
counts
.
lock
);
spin_unlock_irq
(
&
bitmap
->
counts
.
lock
);
if
(
!
init
)
{
if
(
!
init
)
{
bitmap_unplug
(
bitmap
);
md_
bitmap_unplug
(
bitmap
);
bitmap
->
mddev
->
pers
->
quiesce
(
bitmap
->
mddev
,
0
);
bitmap
->
mddev
->
pers
->
quiesce
(
bitmap
->
mddev
,
0
);
}
}
ret
=
0
;
ret
=
0
;
err:
err:
return
ret
;
return
ret
;
}
}
EXPORT_SYMBOL_GPL
(
bitmap_resize
);
EXPORT_SYMBOL_GPL
(
md_
bitmap_resize
);
static
ssize_t
static
ssize_t
location_show
(
struct
mddev
*
mddev
,
char
*
page
)
location_show
(
struct
mddev
*
mddev
,
char
*
page
)
...
@@ -2298,7 +2289,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
...
@@ -2298,7 +2289,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
}
}
if
(
mddev
->
pers
)
{
if
(
mddev
->
pers
)
{
mddev
->
pers
->
quiesce
(
mddev
,
1
);
mddev
->
pers
->
quiesce
(
mddev
,
1
);
bitmap_destroy
(
mddev
);
md_
bitmap_destroy
(
mddev
);
mddev
->
pers
->
quiesce
(
mddev
,
0
);
mddev
->
pers
->
quiesce
(
mddev
,
0
);
}
}
mddev
->
bitmap_info
.
offset
=
0
;
mddev
->
bitmap_info
.
offset
=
0
;
...
@@ -2337,18 +2328,18 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
...
@@ -2337,18 +2328,18 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
if
(
mddev
->
pers
)
{
if
(
mddev
->
pers
)
{
struct
bitmap
*
bitmap
;
struct
bitmap
*
bitmap
;
mddev
->
pers
->
quiesce
(
mddev
,
1
);
mddev
->
pers
->
quiesce
(
mddev
,
1
);
bitmap
=
bitmap_create
(
mddev
,
-
1
);
bitmap
=
md_
bitmap_create
(
mddev
,
-
1
);
if
(
IS_ERR
(
bitmap
))
if
(
IS_ERR
(
bitmap
))
rv
=
PTR_ERR
(
bitmap
);
rv
=
PTR_ERR
(
bitmap
);
else
{
else
{
mddev
->
bitmap
=
bitmap
;
mddev
->
bitmap
=
bitmap
;
rv
=
bitmap_load
(
mddev
);
rv
=
md_
bitmap_load
(
mddev
);
if
(
rv
)
if
(
rv
)
mddev
->
bitmap_info
.
offset
=
0
;
mddev
->
bitmap_info
.
offset
=
0
;
}
}
mddev
->
pers
->
quiesce
(
mddev
,
0
);
mddev
->
pers
->
quiesce
(
mddev
,
0
);
if
(
rv
)
{
if
(
rv
)
{
bitmap_destroy
(
mddev
);
md_
bitmap_destroy
(
mddev
);
goto
out
;
goto
out
;
}
}
}
}
...
...
drivers/md/md-bitmap.h
View file @
5d81a787
...
@@ -236,43 +236,43 @@ struct bitmap {
...
@@ -236,43 +236,43 @@ struct bitmap {
/* the bitmap API */
/* the bitmap API */
/* these are used only by md/bitmap */
/* these are used only by md/bitmap */
struct
bitmap
*
bitmap_create
(
struct
mddev
*
mddev
,
int
slot
);
struct
bitmap
*
md_
bitmap_create
(
struct
mddev
*
mddev
,
int
slot
);
int
bitmap_load
(
struct
mddev
*
mddev
);
int
md_
bitmap_load
(
struct
mddev
*
mddev
);
void
bitmap_flush
(
struct
mddev
*
mddev
);
void
md_
bitmap_flush
(
struct
mddev
*
mddev
);
void
bitmap_destroy
(
struct
mddev
*
mddev
);
void
md_
bitmap_destroy
(
struct
mddev
*
mddev
);
void
bitmap_print_sb
(
struct
bitmap
*
bitmap
);
void
md_
bitmap_print_sb
(
struct
bitmap
*
bitmap
);
void
bitmap_update_sb
(
struct
bitmap
*
bitmap
);
void
md_
bitmap_update_sb
(
struct
bitmap
*
bitmap
);
void
bitmap_status
(
struct
seq_file
*
seq
,
struct
bitmap
*
bitmap
);
void
md_
bitmap_status
(
struct
seq_file
*
seq
,
struct
bitmap
*
bitmap
);
int
bitmap_setallbits
(
struct
bitmap
*
bitmap
);
int
md_
bitmap_setallbits
(
struct
bitmap
*
bitmap
);
void
bitmap_write_all
(
struct
bitmap
*
bitmap
);
void
md_
bitmap_write_all
(
struct
bitmap
*
bitmap
);
void
bitmap_dirty_bits
(
struct
bitmap
*
bitmap
,
unsigned
long
s
,
unsigned
long
e
);
void
md_
bitmap_dirty_bits
(
struct
bitmap
*
bitmap
,
unsigned
long
s
,
unsigned
long
e
);
/* these are exported */
/* these are exported */
int
bitmap_startwrite
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
int
md_
bitmap_startwrite
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
unsigned
long
sectors
,
int
behind
);
unsigned
long
sectors
,
int
behind
);
void
bitmap_endwrite
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
void
md_
bitmap_endwrite
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
unsigned
long
sectors
,
int
success
,
int
behind
);
unsigned
long
sectors
,
int
success
,
int
behind
);
int
bitmap_start_sync
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
sector_t
*
blocks
,
int
degraded
);
int
md_
bitmap_start_sync
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
sector_t
*
blocks
,
int
degraded
);
void
bitmap_end_sync
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
sector_t
*
blocks
,
int
aborted
);
void
md_
bitmap_end_sync
(
struct
bitmap
*
bitmap
,
sector_t
offset
,
sector_t
*
blocks
,
int
aborted
);
void
bitmap_close_sync
(
struct
bitmap
*
bitmap
);
void
md_
bitmap_close_sync
(
struct
bitmap
*
bitmap
);
void
bitmap_cond_end_sync
(
struct
bitmap
*
bitmap
,
sector_t
sector
,
bool
force
);
void
md_
bitmap_cond_end_sync
(
struct
bitmap
*
bitmap
,
sector_t
sector
,
bool
force
);
void
bitmap_sync_with_cluster
(
struct
mddev
*
mddev
,
void
md_
bitmap_sync_with_cluster
(
struct
mddev
*
mddev
,
sector_t
old_lo
,
sector_t
old_hi
,
sector_t
old_lo
,
sector_t
old_hi
,
sector_t
new_lo
,
sector_t
new_hi
);
sector_t
new_lo
,
sector_t
new_hi
);
void
bitmap_unplug
(
struct
bitmap
*
bitmap
);
void
md_
bitmap_unplug
(
struct
bitmap
*
bitmap
);
void
bitmap_daemon_work
(
struct
mddev
*
mddev
);
void
md_
bitmap_daemon_work
(
struct
mddev
*
mddev
);
int
bitmap_resize
(
struct
bitmap
*
bitmap
,
sector_t
blocks
,
int
md_
bitmap_resize
(
struct
bitmap
*
bitmap
,
sector_t
blocks
,
int
chunksize
,
int
init
);
int
chunksize
,
int
init
);
struct
bitmap
*
get_bitmap_from_slot
(
struct
mddev
*
mddev
,
int
slot
);
struct
bitmap
*
get_bitmap_from_slot
(
struct
mddev
*
mddev
,
int
slot
);
int
bitmap_copy_from_slot
(
struct
mddev
*
mddev
,
int
slot
,
int
md_
bitmap_copy_from_slot
(
struct
mddev
*
mddev
,
int
slot
,
sector_t
*
lo
,
sector_t
*
hi
,
bool
clear_bits
);
sector_t
*
lo
,
sector_t
*
hi
,
bool
clear_bits
);
void
bitmap_free
(
struct
bitmap
*
bitmap
);
void
md_
bitmap_free
(
struct
bitmap
*
bitmap
);
void
bitmap_wait_behind_writes
(
struct
mddev
*
mddev
);
void
md_
bitmap_wait_behind_writes
(
struct
mddev
*
mddev
);
#endif
#endif
#endif
#endif
drivers/md/md-cluster.c
View file @
5d81a787
...
@@ -326,7 +326,7 @@ static void recover_bitmaps(struct md_thread *thread)
...
@@ -326,7 +326,7 @@ static void recover_bitmaps(struct md_thread *thread)
str
,
ret
);
str
,
ret
);
goto
clear_bit
;
goto
clear_bit
;
}
}
ret
=
bitmap_copy_from_slot
(
mddev
,
slot
,
&
lo
,
&
hi
,
true
);
ret
=
md_
bitmap_copy_from_slot
(
mddev
,
slot
,
&
lo
,
&
hi
,
true
);
if
(
ret
)
{
if
(
ret
)
{
pr_err
(
"md-cluster: Could not copy data from bitmap %d
\n
"
,
slot
);
pr_err
(
"md-cluster: Could not copy data from bitmap %d
\n
"
,
slot
);
goto
clear_bit
;
goto
clear_bit
;
...
@@ -480,9 +480,7 @@ static void process_suspend_info(struct mddev *mddev,
...
@@ -480,9 +480,7 @@ static void process_suspend_info(struct mddev *mddev,
* resync thread is running in another node,
* resync thread is running in another node,
* so we don't need to do the resync again
* so we don't need to do the resync again
* with the same section */
* with the same section */
bitmap_sync_with_cluster
(
mddev
,
cinfo
->
sync_low
,
md_bitmap_sync_with_cluster
(
mddev
,
cinfo
->
sync_low
,
cinfo
->
sync_hi
,
lo
,
hi
);
cinfo
->
sync_hi
,
lo
,
hi
);
cinfo
->
sync_low
=
lo
;
cinfo
->
sync_low
=
lo
;
cinfo
->
sync_hi
=
hi
;
cinfo
->
sync_hi
=
hi
;
...
@@ -829,7 +827,7 @@ static int gather_all_resync_info(struct mddev *mddev, int total_slots)
...
@@ -829,7 +827,7 @@ static int gather_all_resync_info(struct mddev *mddev, int total_slots)
}
}
/* Read the disk bitmap sb and check if it needs recovery */
/* Read the disk bitmap sb and check if it needs recovery */
ret
=
bitmap_copy_from_slot
(
mddev
,
i
,
&
lo
,
&
hi
,
false
);
ret
=
md_
bitmap_copy_from_slot
(
mddev
,
i
,
&
lo
,
&
hi
,
false
);
if
(
ret
)
{
if
(
ret
)
{
pr_warn
(
"md-cluster: Could not gather bitmaps from slot %d"
,
i
);
pr_warn
(
"md-cluster: Could not gather bitmaps from slot %d"
,
i
);
lockres_free
(
bm_lockres
);
lockres_free
(
bm_lockres
);
...
@@ -1127,13 +1125,13 @@ static int cluster_check_sync_size(struct mddev *mddev)
...
@@ -1127,13 +1125,13 @@ static int cluster_check_sync_size(struct mddev *mddev)
bm_lockres
=
lockres_init
(
mddev
,
str
,
NULL
,
1
);
bm_lockres
=
lockres_init
(
mddev
,
str
,
NULL
,
1
);
if
(
!
bm_lockres
)
{
if
(
!
bm_lockres
)
{
pr_err
(
"md-cluster: Cannot initialize %s
\n
"
,
str
);
pr_err
(
"md-cluster: Cannot initialize %s
\n
"
,
str
);
bitmap_free
(
bitmap
);
md_
bitmap_free
(
bitmap
);
return
-
1
;
return
-
1
;
}
}
bm_lockres
->
flags
|=
DLM_LKF_NOQUEUE
;
bm_lockres
->
flags
|=
DLM_LKF_NOQUEUE
;
rv
=
dlm_lock_sync
(
bm_lockres
,
DLM_LOCK_PW
);
rv
=
dlm_lock_sync
(
bm_lockres
,
DLM_LOCK_PW
);
if
(
!
rv
)
if
(
!
rv
)
bitmap_update_sb
(
bitmap
);
md_
bitmap_update_sb
(
bitmap
);
lockres_free
(
bm_lockres
);
lockres_free
(
bm_lockres
);
sb
=
kmap_atomic
(
bitmap
->
storage
.
sb_page
);
sb
=
kmap_atomic
(
bitmap
->
storage
.
sb_page
);
...
@@ -1141,11 +1139,11 @@ static int cluster_check_sync_size(struct mddev *mddev)
...
@@ -1141,11 +1139,11 @@ static int cluster_check_sync_size(struct mddev *mddev)
sync_size
=
sb
->
sync_size
;
sync_size
=
sb
->
sync_size
;
else
if
(
sync_size
!=
sb
->
sync_size
)
{
else
if
(
sync_size
!=
sb
->
sync_size
)
{
kunmap_atomic
(
sb
);
kunmap_atomic
(
sb
);
bitmap_free
(
bitmap
);
md_
bitmap_free
(
bitmap
);
return
-
1
;
return
-
1
;
}
}
kunmap_atomic
(
sb
);
kunmap_atomic
(
sb
);
bitmap_free
(
bitmap
);
md_
bitmap_free
(
bitmap
);
}
}
return
(
my_sync_size
==
sync_size
)
?
0
:
-
1
;
return
(
my_sync_size
==
sync_size
)
?
0
:
-
1
;
...
@@ -1442,7 +1440,7 @@ static int gather_bitmaps(struct md_rdev *rdev)
...
@@ -1442,7 +1440,7 @@ static int gather_bitmaps(struct md_rdev *rdev)
for
(
sn
=
0
;
sn
<
mddev
->
bitmap_info
.
nodes
;
sn
++
)
{
for
(
sn
=
0
;
sn
<
mddev
->
bitmap_info
.
nodes
;
sn
++
)
{
if
(
sn
==
(
cinfo
->
slot_number
-
1
))
if
(
sn
==
(
cinfo
->
slot_number
-
1
))
continue
;
continue
;
err
=
bitmap_copy_from_slot
(
mddev
,
sn
,
&
lo
,
&
hi
,
false
);
err
=
md_
bitmap_copy_from_slot
(
mddev
,
sn
,
&
lo
,
&
hi
,
false
);
if
(
err
)
{
if
(
err
)
{
pr_warn
(
"md-cluster: Could not gather bitmaps from slot %d"
,
sn
);
pr_warn
(
"md-cluster: Could not gather bitmaps from slot %d"
,
sn
);
goto
out
;
goto
out
;
...
...
drivers/md/md.c
View file @
5d81a787
...
@@ -2560,7 +2560,7 @@ void md_update_sb(struct mddev *mddev, int force_change)
...
@@ -2560,7 +2560,7 @@ void md_update_sb(struct mddev *mddev, int force_change)
if
(
mddev
->
queue
)
if
(
mddev
->
queue
)
blk_add_trace_msg
(
mddev
->
queue
,
"md md_update_sb"
);
blk_add_trace_msg
(
mddev
->
queue
,
"md md_update_sb"
);
rewrite:
rewrite:
bitmap_update_sb
(
mddev
->
bitmap
);
md_
bitmap_update_sb
(
mddev
->
bitmap
);
rdev_for_each
(
rdev
,
mddev
)
{
rdev_for_each
(
rdev
,
mddev
)
{
char
b
[
BDEVNAME_SIZE
];
char
b
[
BDEVNAME_SIZE
];
...
@@ -4372,10 +4372,10 @@ bitmap_store(struct mddev *mddev, const char *buf, size_t len)
...
@@ -4372,10 +4372,10 @@ bitmap_store(struct mddev *mddev, const char *buf, size_t len)
if
(
buf
==
end
)
break
;
if
(
buf
==
end
)
break
;
}
}
if
(
*
end
&&
!
isspace
(
*
end
))
break
;
if
(
*
end
&&
!
isspace
(
*
end
))
break
;
bitmap_dirty_bits
(
mddev
->
bitmap
,
chunk
,
end_chunk
);
md_
bitmap_dirty_bits
(
mddev
->
bitmap
,
chunk
,
end_chunk
);
buf
=
skip_spaces
(
end
);
buf
=
skip_spaces
(
end
);
}
}
bitmap_unplug
(
mddev
->
bitmap
);
/* flush the bits to disk */
md_
bitmap_unplug
(
mddev
->
bitmap
);
/* flush the bits to disk */
out:
out:
mddev_unlock
(
mddev
);
mddev_unlock
(
mddev
);
return
len
;
return
len
;
...
@@ -5588,7 +5588,7 @@ int md_run(struct mddev *mddev)
...
@@ -5588,7 +5588,7 @@ int md_run(struct mddev *mddev)
(
mddev
->
bitmap_info
.
file
||
mddev
->
bitmap_info
.
offset
))
{
(
mddev
->
bitmap_info
.
file
||
mddev
->
bitmap_info
.
offset
))
{
struct
bitmap
*
bitmap
;
struct
bitmap
*
bitmap
;
bitmap
=
bitmap_create
(
mddev
,
-
1
);
bitmap
=
md_
bitmap_create
(
mddev
,
-
1
);
if
(
IS_ERR
(
bitmap
))
{
if
(
IS_ERR
(
bitmap
))
{
err
=
PTR_ERR
(
bitmap
);
err
=
PTR_ERR
(
bitmap
);
pr_warn
(
"%s: failed to create bitmap (%d)
\n
"
,
pr_warn
(
"%s: failed to create bitmap (%d)
\n
"
,
...
@@ -5603,7 +5603,7 @@ int md_run(struct mddev *mddev)
...
@@ -5603,7 +5603,7 @@ int md_run(struct mddev *mddev)
pers
->
free
(
mddev
,
mddev
->
private
);
pers
->
free
(
mddev
,
mddev
->
private
);
mddev
->
private
=
NULL
;
mddev
->
private
=
NULL
;
module_put
(
pers
->
owner
);
module_put
(
pers
->
owner
);
bitmap_destroy
(
mddev
);
md_
bitmap_destroy
(
mddev
);
goto
abort
;
goto
abort
;
}
}
if
(
mddev
->
queue
)
{
if
(
mddev
->
queue
)
{
...
@@ -5688,9 +5688,9 @@ static int do_md_run(struct mddev *mddev)
...
@@ -5688,9 +5688,9 @@ static int do_md_run(struct mddev *mddev)
err
=
md_run
(
mddev
);
err
=
md_run
(
mddev
);
if
(
err
)
if
(
err
)
goto
out
;
goto
out
;
err
=
bitmap_load
(
mddev
);
err
=
md_
bitmap_load
(
mddev
);
if
(
err
)
{
if
(
err
)
{
bitmap_destroy
(
mddev
);
md_
bitmap_destroy
(
mddev
);
goto
out
;
goto
out
;
}
}
...
@@ -5832,7 +5832,7 @@ static void __md_stop_writes(struct mddev *mddev)
...
@@ -5832,7 +5832,7 @@ static void __md_stop_writes(struct mddev *mddev)
mddev
->
pers
->
quiesce
(
mddev
,
1
);
mddev
->
pers
->
quiesce
(
mddev
,
1
);
mddev
->
pers
->
quiesce
(
mddev
,
0
);
mddev
->
pers
->
quiesce
(
mddev
,
0
);
}
}
bitmap_flush
(
mddev
);
md_
bitmap_flush
(
mddev
);
if
(
mddev
->
ro
==
0
&&
if
(
mddev
->
ro
==
0
&&
((
!
mddev
->
in_sync
&&
!
mddev_is_clustered
(
mddev
))
||
((
!
mddev
->
in_sync
&&
!
mddev_is_clustered
(
mddev
))
||
...
@@ -5854,7 +5854,7 @@ EXPORT_SYMBOL_GPL(md_stop_writes);
...
@@ -5854,7 +5854,7 @@ EXPORT_SYMBOL_GPL(md_stop_writes);
static
void
mddev_detach
(
struct
mddev
*
mddev
)
static
void
mddev_detach
(
struct
mddev
*
mddev
)
{
{
bitmap_wait_behind_writes
(
mddev
);
md_
bitmap_wait_behind_writes
(
mddev
);
if
(
mddev
->
pers
&&
mddev
->
pers
->
quiesce
)
{
if
(
mddev
->
pers
&&
mddev
->
pers
->
quiesce
)
{
mddev
->
pers
->
quiesce
(
mddev
,
1
);
mddev
->
pers
->
quiesce
(
mddev
,
1
);
mddev
->
pers
->
quiesce
(
mddev
,
0
);
mddev
->
pers
->
quiesce
(
mddev
,
0
);
...
@@ -5867,7 +5867,7 @@ static void mddev_detach(struct mddev *mddev)
...
@@ -5867,7 +5867,7 @@ static void mddev_detach(struct mddev *mddev)
static
void
__md_stop
(
struct
mddev
*
mddev
)
static
void
__md_stop
(
struct
mddev
*
mddev
)
{
{
struct
md_personality
*
pers
=
mddev
->
pers
;
struct
md_personality
*
pers
=
mddev
->
pers
;
bitmap_destroy
(
mddev
);
md_
bitmap_destroy
(
mddev
);
mddev_detach
(
mddev
);
mddev_detach
(
mddev
);
/* Ensure ->event_work is done */
/* Ensure ->event_work is done */
flush_workqueue
(
md_misc_wq
);
flush_workqueue
(
md_misc_wq
);
...
@@ -6681,21 +6681,21 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
...
@@ -6681,21 +6681,21 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
if
(
fd
>=
0
)
{
if
(
fd
>=
0
)
{
struct
bitmap
*
bitmap
;
struct
bitmap
*
bitmap
;
bitmap
=
bitmap_create
(
mddev
,
-
1
);
bitmap
=
md_
bitmap_create
(
mddev
,
-
1
);
mddev_suspend
(
mddev
);
mddev_suspend
(
mddev
);
if
(
!
IS_ERR
(
bitmap
))
{
if
(
!
IS_ERR
(
bitmap
))
{
mddev
->
bitmap
=
bitmap
;
mddev
->
bitmap
=
bitmap
;
err
=
bitmap_load
(
mddev
);
err
=
md_
bitmap_load
(
mddev
);
}
else
}
else
err
=
PTR_ERR
(
bitmap
);
err
=
PTR_ERR
(
bitmap
);
if
(
err
)
{
if
(
err
)
{
bitmap_destroy
(
mddev
);
md_
bitmap_destroy
(
mddev
);
fd
=
-
1
;
fd
=
-
1
;
}
}
mddev_resume
(
mddev
);
mddev_resume
(
mddev
);
}
else
if
(
fd
<
0
)
{
}
else
if
(
fd
<
0
)
{
mddev_suspend
(
mddev
);
mddev_suspend
(
mddev
);
bitmap_destroy
(
mddev
);
md_
bitmap_destroy
(
mddev
);
mddev_resume
(
mddev
);
mddev_resume
(
mddev
);
}
}
}
}
...
@@ -6981,15 +6981,15 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
...
@@ -6981,15 +6981,15 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
mddev
->
bitmap_info
.
default_offset
;
mddev
->
bitmap_info
.
default_offset
;
mddev
->
bitmap_info
.
space
=
mddev
->
bitmap_info
.
space
=
mddev
->
bitmap_info
.
default_space
;
mddev
->
bitmap_info
.
default_space
;
bitmap
=
bitmap_create
(
mddev
,
-
1
);
bitmap
=
md_
bitmap_create
(
mddev
,
-
1
);
mddev_suspend
(
mddev
);
mddev_suspend
(
mddev
);
if
(
!
IS_ERR
(
bitmap
))
{
if
(
!
IS_ERR
(
bitmap
))
{
mddev
->
bitmap
=
bitmap
;
mddev
->
bitmap
=
bitmap
;
rv
=
bitmap_load
(
mddev
);
rv
=
md_
bitmap_load
(
mddev
);
}
else
}
else
rv
=
PTR_ERR
(
bitmap
);
rv
=
PTR_ERR
(
bitmap
);
if
(
rv
)
if
(
rv
)
bitmap_destroy
(
mddev
);
md_
bitmap_destroy
(
mddev
);
mddev_resume
(
mddev
);
mddev_resume
(
mddev
);
}
else
{
}
else
{
/* remove the bitmap */
/* remove the bitmap */
...
@@ -7014,7 +7014,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
...
@@ -7014,7 +7014,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
md_cluster_ops
->
leave
(
mddev
);
md_cluster_ops
->
leave
(
mddev
);
}
}
mddev_suspend
(
mddev
);
mddev_suspend
(
mddev
);
bitmap_destroy
(
mddev
);
md_
bitmap_destroy
(
mddev
);
mddev_resume
(
mddev
);
mddev_resume
(
mddev
);
mddev
->
bitmap_info
.
offset
=
0
;
mddev
->
bitmap_info
.
offset
=
0
;
}
}
...
@@ -7877,7 +7877,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
...
@@ -7877,7 +7877,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
}
else
}
else
seq_printf
(
seq
,
"
\n
"
);
seq_printf
(
seq
,
"
\n
"
);
bitmap_status
(
seq
,
mddev
->
bitmap
);
md_
bitmap_status
(
seq
,
mddev
->
bitmap
);
seq_printf
(
seq
,
"
\n
"
);
seq_printf
(
seq
,
"
\n
"
);
}
}
...
@@ -8748,7 +8748,7 @@ void md_check_recovery(struct mddev *mddev)
...
@@ -8748,7 +8748,7 @@ void md_check_recovery(struct mddev *mddev)
return
;
return
;
if
(
mddev
->
bitmap
)
if
(
mddev
->
bitmap
)
bitmap_daemon_work
(
mddev
);
md_
bitmap_daemon_work
(
mddev
);
if
(
signal_pending
(
current
))
{
if
(
signal_pending
(
current
))
{
if
(
mddev
->
pers
->
sync_request
&&
!
mddev
->
external
)
{
if
(
mddev
->
pers
->
sync_request
&&
!
mddev
->
external
)
{
...
@@ -8885,7 +8885,7 @@ void md_check_recovery(struct mddev *mddev)
...
@@ -8885,7 +8885,7 @@ void md_check_recovery(struct mddev *mddev)
* which has the bitmap stored on all devices.
* which has the bitmap stored on all devices.
* So make sure all bitmap pages get written
* So make sure all bitmap pages get written
*/
*/
bitmap_write_all
(
mddev
->
bitmap
);
md_
bitmap_write_all
(
mddev
->
bitmap
);
}
}
INIT_WORK
(
&
mddev
->
del_work
,
md_start_sync
);
INIT_WORK
(
&
mddev
->
del_work
,
md_start_sync
);
queue_work
(
md_misc_wq
,
&
mddev
->
del_work
);
queue_work
(
md_misc_wq
,
&
mddev
->
del_work
);
...
@@ -9133,7 +9133,7 @@ static void check_sb_changes(struct mddev *mddev, struct md_rdev *rdev)
...
@@ -9133,7 +9133,7 @@ static void check_sb_changes(struct mddev *mddev, struct md_rdev *rdev)
if
(
ret
)
if
(
ret
)
pr_info
(
"md-cluster: resize failed
\n
"
);
pr_info
(
"md-cluster: resize failed
\n
"
);
else
else
bitmap_update_sb
(
mddev
->
bitmap
);
md_
bitmap_update_sb
(
mddev
->
bitmap
);
}
}
/* Check for change of roles in the active devices */
/* Check for change of roles in the active devices */
...
...
drivers/md/persistent-data/dm-space-map-common.c
View file @
5d81a787
...
@@ -69,7 +69,7 @@ static struct dm_block_validator index_validator = {
...
@@ -69,7 +69,7 @@ static struct dm_block_validator index_validator = {
*/
*/
#define BITMAP_CSUM_XOR 240779
#define BITMAP_CSUM_XOR 240779
static
void
bitmap_prepare_for_write
(
struct
dm_block_validator
*
v
,
static
void
dm_
bitmap_prepare_for_write
(
struct
dm_block_validator
*
v
,
struct
dm_block
*
b
,
struct
dm_block
*
b
,
size_t
block_size
)
size_t
block_size
)
{
{
...
@@ -81,7 +81,7 @@ static void bitmap_prepare_for_write(struct dm_block_validator *v,
...
@@ -81,7 +81,7 @@ static void bitmap_prepare_for_write(struct dm_block_validator *v,
BITMAP_CSUM_XOR
));
BITMAP_CSUM_XOR
));
}
}
static
int
bitmap_check
(
struct
dm_block_validator
*
v
,
static
int
dm_
bitmap_check
(
struct
dm_block_validator
*
v
,
struct
dm_block
*
b
,
struct
dm_block
*
b
,
size_t
block_size
)
size_t
block_size
)
{
{
...
@@ -108,8 +108,8 @@ static int bitmap_check(struct dm_block_validator *v,
...
@@ -108,8 +108,8 @@ static int bitmap_check(struct dm_block_validator *v,
static
struct
dm_block_validator
dm_sm_bitmap_validator
=
{
static
struct
dm_block_validator
dm_sm_bitmap_validator
=
{
.
name
=
"sm_bitmap"
,
.
name
=
"sm_bitmap"
,
.
prepare_for_write
=
bitmap_prepare_for_write
,
.
prepare_for_write
=
dm_
bitmap_prepare_for_write
,
.
check
=
bitmap_check
.
check
=
dm_bitmap_check
,
};
};
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
...
@@ -124,7 +124,7 @@ static void *dm_bitmap_data(struct dm_block *b)
...
@@ -124,7 +124,7 @@ static void *dm_bitmap_data(struct dm_block *b)
#define WORD_MASK_HIGH 0xAAAAAAAAAAAAAAAAULL
#define WORD_MASK_HIGH 0xAAAAAAAAAAAAAAAAULL
static
unsigned
bitmap_word_used
(
void
*
addr
,
unsigned
b
)
static
unsigned
dm_
bitmap_word_used
(
void
*
addr
,
unsigned
b
)
{
{
__le64
*
words_le
=
addr
;
__le64
*
words_le
=
addr
;
__le64
*
w_le
=
words_le
+
(
b
>>
ENTRIES_SHIFT
);
__le64
*
w_le
=
words_le
+
(
b
>>
ENTRIES_SHIFT
);
...
@@ -170,7 +170,7 @@ static int sm_find_free(void *addr, unsigned begin, unsigned end,
...
@@ -170,7 +170,7 @@ static int sm_find_free(void *addr, unsigned begin, unsigned end,
{
{
while
(
begin
<
end
)
{
while
(
begin
<
end
)
{
if
(
!
(
begin
&
(
ENTRIES_PER_WORD
-
1
))
&&
if
(
!
(
begin
&
(
ENTRIES_PER_WORD
-
1
))
&&
bitmap_word_used
(
addr
,
begin
))
{
dm_
bitmap_word_used
(
addr
,
begin
))
{
begin
+=
ENTRIES_PER_WORD
;
begin
+=
ENTRIES_PER_WORD
;
continue
;
continue
;
}
}
...
...
drivers/md/raid1.c
View file @
5d81a787
...
@@ -385,7 +385,7 @@ static void close_write(struct r1bio *r1_bio)
...
@@ -385,7 +385,7 @@ static void close_write(struct r1bio *r1_bio)
r1_bio
->
behind_master_bio
=
NULL
;
r1_bio
->
behind_master_bio
=
NULL
;
}
}
/* clear the bitmap if all writes complete successfully */
/* clear the bitmap if all writes complete successfully */
bitmap_endwrite
(
r1_bio
->
mddev
->
bitmap
,
r1_bio
->
sector
,
md_
bitmap_endwrite
(
r1_bio
->
mddev
->
bitmap
,
r1_bio
->
sector
,
r1_bio
->
sectors
,
r1_bio
->
sectors
,
!
test_bit
(
R1BIO_Degraded
,
&
r1_bio
->
state
),
!
test_bit
(
R1BIO_Degraded
,
&
r1_bio
->
state
),
test_bit
(
R1BIO_BehindIO
,
&
r1_bio
->
state
));
test_bit
(
R1BIO_BehindIO
,
&
r1_bio
->
state
));
...
@@ -781,7 +781,7 @@ static int raid1_congested(struct mddev *mddev, int bits)
...
@@ -781,7 +781,7 @@ static int raid1_congested(struct mddev *mddev, int bits)
static
void
flush_bio_list
(
struct
r1conf
*
conf
,
struct
bio
*
bio
)
static
void
flush_bio_list
(
struct
r1conf
*
conf
,
struct
bio
*
bio
)
{
{
/* flush any pending bitmap writes to disk before proceeding w/ I/O */
/* flush any pending bitmap writes to disk before proceeding w/ I/O */
bitmap_unplug
(
conf
->
mddev
->
bitmap
);
md_
bitmap_unplug
(
conf
->
mddev
->
bitmap
);
wake_up
(
&
conf
->
wait_barrier
);
wake_up
(
&
conf
->
wait_barrier
);
while
(
bio
)
{
/* submit pending writes */
while
(
bio
)
{
/* submit pending writes */
...
@@ -1470,10 +1470,8 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
...
@@ -1470,10 +1470,8 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
alloc_behind_master_bio
(
r1_bio
,
bio
);
alloc_behind_master_bio
(
r1_bio
,
bio
);
}
}
bitmap_startwrite
(
bitmap
,
r1_bio
->
sector
,
md_bitmap_startwrite
(
bitmap
,
r1_bio
->
sector
,
r1_bio
->
sectors
,
r1_bio
->
sectors
,
test_bit
(
R1BIO_BehindIO
,
&
r1_bio
->
state
));
test_bit
(
R1BIO_BehindIO
,
&
r1_bio
->
state
));
first_clone
=
0
;
first_clone
=
0
;
}
}
...
@@ -1881,8 +1879,7 @@ static void end_sync_write(struct bio *bio)
...
@@ -1881,8 +1879,7 @@ static void end_sync_write(struct bio *bio)
long
sectors_to_go
=
r1_bio
->
sectors
;
long
sectors_to_go
=
r1_bio
->
sectors
;
/* make sure these bits doesn't get cleared. */
/* make sure these bits doesn't get cleared. */
do
{
do
{
bitmap_end_sync
(
mddev
->
bitmap
,
s
,
md_bitmap_end_sync
(
mddev
->
bitmap
,
s
,
&
sync_blocks
,
1
);
&
sync_blocks
,
1
);
s
+=
sync_blocks
;
s
+=
sync_blocks
;
sectors_to_go
-=
sync_blocks
;
sectors_to_go
-=
sync_blocks
;
}
while
(
sectors_to_go
>
0
);
}
while
(
sectors_to_go
>
0
);
...
@@ -2629,12 +2626,12 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
...
@@ -2629,12 +2626,12 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
* We can find the current addess in mddev->curr_resync
* We can find the current addess in mddev->curr_resync
*/
*/
if
(
mddev
->
curr_resync
<
max_sector
)
/* aborted */
if
(
mddev
->
curr_resync
<
max_sector
)
/* aborted */
bitmap_end_sync
(
mddev
->
bitmap
,
mddev
->
curr_resync
,
md_
bitmap_end_sync
(
mddev
->
bitmap
,
mddev
->
curr_resync
,
&
sync_blocks
,
1
);
&
sync_blocks
,
1
);
else
/* completed sync */
else
/* completed sync */
conf
->
fullsync
=
0
;
conf
->
fullsync
=
0
;
bitmap_close_sync
(
mddev
->
bitmap
);
md_
bitmap_close_sync
(
mddev
->
bitmap
);
close_sync
(
conf
);
close_sync
(
conf
);
if
(
mddev_is_clustered
(
mddev
))
{
if
(
mddev_is_clustered
(
mddev
))
{
...
@@ -2654,7 +2651,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
...
@@ -2654,7 +2651,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
/* before building a request, check if we can skip these blocks..
/* before building a request, check if we can skip these blocks..
* This call the bitmap_start_sync doesn't actually record anything
* This call the bitmap_start_sync doesn't actually record anything
*/
*/
if
(
!
bitmap_start_sync
(
mddev
->
bitmap
,
sector_nr
,
&
sync_blocks
,
1
)
&&
if
(
!
md_
bitmap_start_sync
(
mddev
->
bitmap
,
sector_nr
,
&
sync_blocks
,
1
)
&&
!
conf
->
fullsync
&&
!
test_bit
(
MD_RECOVERY_REQUESTED
,
&
mddev
->
recovery
))
{
!
conf
->
fullsync
&&
!
test_bit
(
MD_RECOVERY_REQUESTED
,
&
mddev
->
recovery
))
{
/* We can skip this block, and probably several more */
/* We can skip this block, and probably several more */
*
skipped
=
1
;
*
skipped
=
1
;
...
@@ -2672,7 +2669,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
...
@@ -2672,7 +2669,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
* sector_nr + two times RESYNC_SECTORS
* sector_nr + two times RESYNC_SECTORS
*/
*/
bitmap_cond_end_sync
(
mddev
->
bitmap
,
sector_nr
,
md_
bitmap_cond_end_sync
(
mddev
->
bitmap
,
sector_nr
,
mddev_is_clustered
(
mddev
)
&&
(
sector_nr
+
2
*
RESYNC_SECTORS
>
conf
->
cluster_sync_high
));
mddev_is_clustered
(
mddev
)
&&
(
sector_nr
+
2
*
RESYNC_SECTORS
>
conf
->
cluster_sync_high
));
...
@@ -2831,7 +2828,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
...
@@ -2831,7 +2828,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
if
(
len
==
0
)
if
(
len
==
0
)
break
;
break
;
if
(
sync_blocks
==
0
)
{
if
(
sync_blocks
==
0
)
{
if
(
!
bitmap_start_sync
(
mddev
->
bitmap
,
sector_nr
,
if
(
!
md_
bitmap_start_sync
(
mddev
->
bitmap
,
sector_nr
,
&
sync_blocks
,
still_degraded
)
&&
&
sync_blocks
,
still_degraded
)
&&
!
conf
->
fullsync
&&
!
conf
->
fullsync
&&
!
test_bit
(
MD_RECOVERY_REQUESTED
,
&
mddev
->
recovery
))
!
test_bit
(
MD_RECOVERY_REQUESTED
,
&
mddev
->
recovery
))
...
@@ -3171,7 +3168,7 @@ static int raid1_resize(struct mddev *mddev, sector_t sectors)
...
@@ -3171,7 +3168,7 @@ static int raid1_resize(struct mddev *mddev, sector_t sectors)
mddev
->
array_sectors
>
newsize
)
mddev
->
array_sectors
>
newsize
)
return
-
EINVAL
;
return
-
EINVAL
;
if
(
mddev
->
bitmap
)
{
if
(
mddev
->
bitmap
)
{
int
ret
=
bitmap_resize
(
mddev
->
bitmap
,
newsize
,
0
,
0
);
int
ret
=
md_
bitmap_resize
(
mddev
->
bitmap
,
newsize
,
0
,
0
);
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
}
}
...
...
drivers/md/raid10.c
View file @
5d81a787
...
@@ -438,7 +438,7 @@ static void raid10_end_read_request(struct bio *bio)
...
@@ -438,7 +438,7 @@ static void raid10_end_read_request(struct bio *bio)
static
void
close_write
(
struct
r10bio
*
r10_bio
)
static
void
close_write
(
struct
r10bio
*
r10_bio
)
{
{
/* clear the bitmap if all writes complete successfully */
/* clear the bitmap if all writes complete successfully */
bitmap_endwrite
(
r10_bio
->
mddev
->
bitmap
,
r10_bio
->
sector
,
md_
bitmap_endwrite
(
r10_bio
->
mddev
->
bitmap
,
r10_bio
->
sector
,
r10_bio
->
sectors
,
r10_bio
->
sectors
,
!
test_bit
(
R10BIO_Degraded
,
&
r10_bio
->
state
),
!
test_bit
(
R10BIO_Degraded
,
&
r10_bio
->
state
),
0
);
0
);
...
@@ -915,7 +915,7 @@ static void flush_pending_writes(struct r10conf *conf)
...
@@ -915,7 +915,7 @@ static void flush_pending_writes(struct r10conf *conf)
blk_start_plug
(
&
plug
);
blk_start_plug
(
&
plug
);
/* flush any pending bitmap writes to disk
/* flush any pending bitmap writes to disk
* before proceeding w/ I/O */
* before proceeding w/ I/O */
bitmap_unplug
(
conf
->
mddev
->
bitmap
);
md_
bitmap_unplug
(
conf
->
mddev
->
bitmap
);
wake_up
(
&
conf
->
wait_barrier
);
wake_up
(
&
conf
->
wait_barrier
);
while
(
bio
)
{
/* submit pending writes */
while
(
bio
)
{
/* submit pending writes */
...
@@ -1100,7 +1100,7 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule)
...
@@ -1100,7 +1100,7 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule)
/* we aren't scheduling, so we can do the write-out directly. */
/* we aren't scheduling, so we can do the write-out directly. */
bio
=
bio_list_get
(
&
plug
->
pending
);
bio
=
bio_list_get
(
&
plug
->
pending
);
bitmap_unplug
(
mddev
->
bitmap
);
md_
bitmap_unplug
(
mddev
->
bitmap
);
wake_up
(
&
conf
->
wait_barrier
);
wake_up
(
&
conf
->
wait_barrier
);
while
(
bio
)
{
/* submit pending writes */
while
(
bio
)
{
/* submit pending writes */
...
@@ -1517,7 +1517,7 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,
...
@@ -1517,7 +1517,7 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,
}
}
atomic_set
(
&
r10_bio
->
remaining
,
1
);
atomic_set
(
&
r10_bio
->
remaining
,
1
);
bitmap_startwrite
(
mddev
->
bitmap
,
r10_bio
->
sector
,
r10_bio
->
sectors
,
0
);
md_
bitmap_startwrite
(
mddev
->
bitmap
,
r10_bio
->
sector
,
r10_bio
->
sectors
,
0
);
for
(
i
=
0
;
i
<
conf
->
copies
;
i
++
)
{
for
(
i
=
0
;
i
<
conf
->
copies
;
i
++
)
{
if
(
r10_bio
->
devs
[
i
].
bio
)
if
(
r10_bio
->
devs
[
i
].
bio
)
...
@@ -2990,12 +2990,12 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
...
@@ -2990,12 +2990,12 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
if
(
mddev
->
curr_resync
<
max_sector
)
{
/* aborted */
if
(
mddev
->
curr_resync
<
max_sector
)
{
/* aborted */
if
(
test_bit
(
MD_RECOVERY_SYNC
,
&
mddev
->
recovery
))
if
(
test_bit
(
MD_RECOVERY_SYNC
,
&
mddev
->
recovery
))
bitmap_end_sync
(
mddev
->
bitmap
,
mddev
->
curr_resync
,
md_
bitmap_end_sync
(
mddev
->
bitmap
,
mddev
->
curr_resync
,
&
sync_blocks
,
1
);
&
sync_blocks
,
1
);
else
for
(
i
=
0
;
i
<
conf
->
geo
.
raid_disks
;
i
++
)
{
else
for
(
i
=
0
;
i
<
conf
->
geo
.
raid_disks
;
i
++
)
{
sector_t
sect
=
sector_t
sect
=
raid10_find_virt
(
conf
,
mddev
->
curr_resync
,
i
);
raid10_find_virt
(
conf
,
mddev
->
curr_resync
,
i
);
bitmap_end_sync
(
mddev
->
bitmap
,
sect
,
md_
bitmap_end_sync
(
mddev
->
bitmap
,
sect
,
&
sync_blocks
,
1
);
&
sync_blocks
,
1
);
}
}
}
else
{
}
else
{
...
@@ -3017,7 +3017,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
...
@@ -3017,7 +3017,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
}
}
conf
->
fullsync
=
0
;
conf
->
fullsync
=
0
;
}
}
bitmap_close_sync
(
mddev
->
bitmap
);
md_
bitmap_close_sync
(
mddev
->
bitmap
);
close_sync
(
conf
);
close_sync
(
conf
);
*
skipped
=
1
;
*
skipped
=
1
;
return
sectors_skipped
;
return
sectors_skipped
;
...
@@ -3111,7 +3111,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
...
@@ -3111,7 +3111,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
* we only need to recover the block if it is set in
* we only need to recover the block if it is set in
* the bitmap
* the bitmap
*/
*/
must_sync
=
bitmap_start_sync
(
mddev
->
bitmap
,
sect
,
must_sync
=
md_
bitmap_start_sync
(
mddev
->
bitmap
,
sect
,
&
sync_blocks
,
1
);
&
sync_blocks
,
1
);
if
(
sync_blocks
<
max_sync
)
if
(
sync_blocks
<
max_sync
)
max_sync
=
sync_blocks
;
max_sync
=
sync_blocks
;
...
@@ -3157,7 +3157,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
...
@@ -3157,7 +3157,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
}
}
}
}
must_sync
=
bitmap_start_sync
(
mddev
->
bitmap
,
sect
,
must_sync
=
md_
bitmap_start_sync
(
mddev
->
bitmap
,
sect
,
&
sync_blocks
,
still_degraded
);
&
sync_blocks
,
still_degraded
);
any_working
=
0
;
any_working
=
0
;
...
@@ -3334,12 +3334,11 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
...
@@ -3334,12 +3334,11 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
* safety reason, which ensures curr_resync_completed is
* safety reason, which ensures curr_resync_completed is
* updated in bitmap_cond_end_sync.
* updated in bitmap_cond_end_sync.
*/
*/
bitmap_cond_end_sync
(
mddev
->
bitmap
,
sector_nr
,
md_
bitmap_cond_end_sync
(
mddev
->
bitmap
,
sector_nr
,
mddev_is_clustered
(
mddev
)
&&
mddev_is_clustered
(
mddev
)
&&
(
sector_nr
+
2
*
RESYNC_SECTORS
>
(
sector_nr
+
2
*
RESYNC_SECTORS
>
conf
->
cluster_sync_high
));
conf
->
cluster_sync_high
));
if
(
!
bitmap_start_sync
(
mddev
->
bitmap
,
sector_nr
,
if
(
!
md_
bitmap_start_sync
(
mddev
->
bitmap
,
sector_nr
,
&
sync_blocks
,
mddev
->
degraded
)
&&
&
sync_blocks
,
mddev
->
degraded
)
&&
!
conf
->
fullsync
&&
!
test_bit
(
MD_RECOVERY_REQUESTED
,
!
conf
->
fullsync
&&
!
test_bit
(
MD_RECOVERY_REQUESTED
,
&
mddev
->
recovery
))
{
&
mddev
->
recovery
))
{
...
@@ -4015,7 +4014,7 @@ static int raid10_resize(struct mddev *mddev, sector_t sectors)
...
@@ -4015,7 +4014,7 @@ static int raid10_resize(struct mddev *mddev, sector_t sectors)
mddev
->
array_sectors
>
size
)
mddev
->
array_sectors
>
size
)
return
-
EINVAL
;
return
-
EINVAL
;
if
(
mddev
->
bitmap
)
{
if
(
mddev
->
bitmap
)
{
int
ret
=
bitmap_resize
(
mddev
->
bitmap
,
size
,
0
,
0
);
int
ret
=
md_
bitmap_resize
(
mddev
->
bitmap
,
size
,
0
,
0
);
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
}
}
...
@@ -4281,9 +4280,8 @@ static int raid10_start_reshape(struct mddev *mddev)
...
@@ -4281,9 +4280,8 @@ static int raid10_start_reshape(struct mddev *mddev)
spin_unlock_irq
(
&
conf
->
device_lock
);
spin_unlock_irq
(
&
conf
->
device_lock
);
if
(
mddev
->
delta_disks
&&
mddev
->
bitmap
)
{
if
(
mddev
->
delta_disks
&&
mddev
->
bitmap
)
{
ret
=
bitmap_resize
(
mddev
->
bitmap
,
ret
=
md_bitmap_resize
(
mddev
->
bitmap
,
raid10_size
(
mddev
,
0
,
raid10_size
(
mddev
,
0
,
conf
->
geo
.
raid_disks
),
conf
->
geo
.
raid_disks
),
0
,
0
);
0
,
0
);
if
(
ret
)
if
(
ret
)
goto
abort
;
goto
abort
;
...
...
drivers/md/raid5-cache.c
View file @
5d81a787
...
@@ -324,7 +324,7 @@ void r5c_handle_cached_data_endio(struct r5conf *conf,
...
@@ -324,7 +324,7 @@ void r5c_handle_cached_data_endio(struct r5conf *conf,
if
(
sh
->
dev
[
i
].
written
)
{
if
(
sh
->
dev
[
i
].
written
)
{
set_bit
(
R5_UPTODATE
,
&
sh
->
dev
[
i
].
flags
);
set_bit
(
R5_UPTODATE
,
&
sh
->
dev
[
i
].
flags
);
r5c_return_dev_pending_writes
(
conf
,
&
sh
->
dev
[
i
]);
r5c_return_dev_pending_writes
(
conf
,
&
sh
->
dev
[
i
]);
bitmap_endwrite
(
conf
->
mddev
->
bitmap
,
sh
->
sector
,
md_
bitmap_endwrite
(
conf
->
mddev
->
bitmap
,
sh
->
sector
,
STRIPE_SECTORS
,
STRIPE_SECTORS
,
!
test_bit
(
STRIPE_DEGRADED
,
&
sh
->
state
),
!
test_bit
(
STRIPE_DEGRADED
,
&
sh
->
state
),
0
);
0
);
...
...
drivers/md/raid5.c
View file @
5d81a787
...
@@ -3295,7 +3295,7 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx,
...
@@ -3295,7 +3295,7 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx,
*/
*/
set_bit
(
STRIPE_BITMAP_PENDING
,
&
sh
->
state
);
set_bit
(
STRIPE_BITMAP_PENDING
,
&
sh
->
state
);
spin_unlock_irq
(
&
sh
->
stripe_lock
);
spin_unlock_irq
(
&
sh
->
stripe_lock
);
bitmap_startwrite
(
conf
->
mddev
->
bitmap
,
sh
->
sector
,
md_
bitmap_startwrite
(
conf
->
mddev
->
bitmap
,
sh
->
sector
,
STRIPE_SECTORS
,
0
);
STRIPE_SECTORS
,
0
);
spin_lock_irq
(
&
sh
->
stripe_lock
);
spin_lock_irq
(
&
sh
->
stripe_lock
);
clear_bit
(
STRIPE_BITMAP_PENDING
,
&
sh
->
state
);
clear_bit
(
STRIPE_BITMAP_PENDING
,
&
sh
->
state
);
...
@@ -3386,7 +3386,7 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
...
@@ -3386,7 +3386,7 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
bi
=
nextbi
;
bi
=
nextbi
;
}
}
if
(
bitmap_end
)
if
(
bitmap_end
)
bitmap_endwrite
(
conf
->
mddev
->
bitmap
,
sh
->
sector
,
md_
bitmap_endwrite
(
conf
->
mddev
->
bitmap
,
sh
->
sector
,
STRIPE_SECTORS
,
0
,
0
);
STRIPE_SECTORS
,
0
,
0
);
bitmap_end
=
0
;
bitmap_end
=
0
;
/* and fail all 'written' */
/* and fail all 'written' */
...
@@ -3432,7 +3432,7 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
...
@@ -3432,7 +3432,7 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
}
}
}
}
if
(
bitmap_end
)
if
(
bitmap_end
)
bitmap_endwrite
(
conf
->
mddev
->
bitmap
,
sh
->
sector
,
md_
bitmap_endwrite
(
conf
->
mddev
->
bitmap
,
sh
->
sector
,
STRIPE_SECTORS
,
0
,
0
);
STRIPE_SECTORS
,
0
,
0
);
/* If we were in the middle of a write the parity block might
/* If we were in the middle of a write the parity block might
* still be locked - so just clear all R5_LOCKED flags
* still be locked - so just clear all R5_LOCKED flags
...
@@ -3773,7 +3773,7 @@ static void handle_stripe_clean_event(struct r5conf *conf,
...
@@ -3773,7 +3773,7 @@ static void handle_stripe_clean_event(struct r5conf *conf,
bio_endio
(
wbi
);
bio_endio
(
wbi
);
wbi
=
wbi2
;
wbi
=
wbi2
;
}
}
bitmap_endwrite
(
conf
->
mddev
->
bitmap
,
sh
->
sector
,
md_
bitmap_endwrite
(
conf
->
mddev
->
bitmap
,
sh
->
sector
,
STRIPE_SECTORS
,
STRIPE_SECTORS
,
!
test_bit
(
STRIPE_DEGRADED
,
&
sh
->
state
),
!
test_bit
(
STRIPE_DEGRADED
,
&
sh
->
state
),
0
);
0
);
...
@@ -5533,7 +5533,7 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
...
@@ -5533,7 +5533,7 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
for
(
d
=
0
;
for
(
d
=
0
;
d
<
conf
->
raid_disks
-
conf
->
max_degraded
;
d
<
conf
->
raid_disks
-
conf
->
max_degraded
;
d
++
)
d
++
)
bitmap_startwrite
(
mddev
->
bitmap
,
md_
bitmap_startwrite
(
mddev
->
bitmap
,
sh
->
sector
,
sh
->
sector
,
STRIPE_SECTORS
,
STRIPE_SECTORS
,
0
);
0
);
...
@@ -6014,11 +6014,11 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
...
@@ -6014,11 +6014,11 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
}
}
if
(
mddev
->
curr_resync
<
max_sector
)
/* aborted */
if
(
mddev
->
curr_resync
<
max_sector
)
/* aborted */
bitmap_end_sync
(
mddev
->
bitmap
,
mddev
->
curr_resync
,
md_
bitmap_end_sync
(
mddev
->
bitmap
,
mddev
->
curr_resync
,
&
sync_blocks
,
1
);
&
sync_blocks
,
1
);
else
/* completed sync */
else
/* completed sync */
conf
->
fullsync
=
0
;
conf
->
fullsync
=
0
;
bitmap_close_sync
(
mddev
->
bitmap
);
md_
bitmap_close_sync
(
mddev
->
bitmap
);
return
0
;
return
0
;
}
}
...
@@ -6047,7 +6047,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
...
@@ -6047,7 +6047,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
}
}
if
(
!
test_bit
(
MD_RECOVERY_REQUESTED
,
&
mddev
->
recovery
)
&&
if
(
!
test_bit
(
MD_RECOVERY_REQUESTED
,
&
mddev
->
recovery
)
&&
!
conf
->
fullsync
&&
!
conf
->
fullsync
&&
!
bitmap_start_sync
(
mddev
->
bitmap
,
sector_nr
,
&
sync_blocks
,
1
)
&&
!
md_
bitmap_start_sync
(
mddev
->
bitmap
,
sector_nr
,
&
sync_blocks
,
1
)
&&
sync_blocks
>=
STRIPE_SECTORS
)
{
sync_blocks
>=
STRIPE_SECTORS
)
{
/* we can skip this block, and probably more */
/* we can skip this block, and probably more */
sync_blocks
/=
STRIPE_SECTORS
;
sync_blocks
/=
STRIPE_SECTORS
;
...
@@ -6055,7 +6055,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
...
@@ -6055,7 +6055,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
return
sync_blocks
*
STRIPE_SECTORS
;
/* keep things rounded to whole stripes */
return
sync_blocks
*
STRIPE_SECTORS
;
/* keep things rounded to whole stripes */
}
}
bitmap_cond_end_sync
(
mddev
->
bitmap
,
sector_nr
,
false
);
md_
bitmap_cond_end_sync
(
mddev
->
bitmap
,
sector_nr
,
false
);
sh
=
raid5_get_active_stripe
(
conf
,
sector_nr
,
0
,
1
,
0
);
sh
=
raid5_get_active_stripe
(
conf
,
sector_nr
,
0
,
1
,
0
);
if
(
sh
==
NULL
)
{
if
(
sh
==
NULL
)
{
...
@@ -6078,7 +6078,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
...
@@ -6078,7 +6078,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
}
}
rcu_read_unlock
();
rcu_read_unlock
();
bitmap_start_sync
(
mddev
->
bitmap
,
sector_nr
,
&
sync_blocks
,
still_degraded
);
md_
bitmap_start_sync
(
mddev
->
bitmap
,
sector_nr
,
&
sync_blocks
,
still_degraded
);
set_bit
(
STRIPE_SYNC_REQUESTED
,
&
sh
->
state
);
set_bit
(
STRIPE_SYNC_REQUESTED
,
&
sh
->
state
);
set_bit
(
STRIPE_HANDLE
,
&
sh
->
state
);
set_bit
(
STRIPE_HANDLE
,
&
sh
->
state
);
...
@@ -6279,7 +6279,7 @@ static void raid5d(struct md_thread *thread)
...
@@ -6279,7 +6279,7 @@ static void raid5d(struct md_thread *thread)
/* Now is a good time to flush some bitmap updates */
/* Now is a good time to flush some bitmap updates */
conf
->
seq_flush
++
;
conf
->
seq_flush
++
;
spin_unlock_irq
(
&
conf
->
device_lock
);
spin_unlock_irq
(
&
conf
->
device_lock
);
bitmap_unplug
(
mddev
->
bitmap
);
md_
bitmap_unplug
(
mddev
->
bitmap
);
spin_lock_irq
(
&
conf
->
device_lock
);
spin_lock_irq
(
&
conf
->
device_lock
);
conf
->
seq_write
=
conf
->
seq_flush
;
conf
->
seq_write
=
conf
->
seq_flush
;
activate_bit_delay
(
conf
,
conf
->
temp_inactive_list
);
activate_bit_delay
(
conf
,
conf
->
temp_inactive_list
);
...
@@ -7734,7 +7734,7 @@ static int raid5_resize(struct mddev *mddev, sector_t sectors)
...
@@ -7734,7 +7734,7 @@ static int raid5_resize(struct mddev *mddev, sector_t sectors)
mddev
->
array_sectors
>
newsize
)
mddev
->
array_sectors
>
newsize
)
return
-
EINVAL
;
return
-
EINVAL
;
if
(
mddev
->
bitmap
)
{
if
(
mddev
->
bitmap
)
{
int
ret
=
bitmap_resize
(
mddev
->
bitmap
,
sectors
,
0
,
0
);
int
ret
=
md_
bitmap_resize
(
mddev
->
bitmap
,
sectors
,
0
,
0
);
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
}
}
...
...
include/linux/bitmap.h
View file @
5d81a787
...
@@ -104,6 +104,14 @@
...
@@ -104,6 +104,14 @@
* contain all bit positions from 0 to 'bits' - 1.
* contain all bit positions from 0 to 'bits' - 1.
*/
*/
/*
* Allocation and deallocation of bitmap.
* Provided in lib/bitmap.c to avoid circular dependency.
*/
extern
unsigned
long
*
bitmap_alloc
(
unsigned
int
nbits
,
gfp_t
flags
);
extern
unsigned
long
*
bitmap_zalloc
(
unsigned
int
nbits
,
gfp_t
flags
);
extern
void
bitmap_free
(
const
unsigned
long
*
bitmap
);
/*
/*
* lib/bitmap.c provides these functions:
* lib/bitmap.c provides these functions:
*/
*/
...
...
lib/bitmap.c
View file @
5d81a787
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include <linux/bitops.h>
#include <linux/bitops.h>
#include <linux/bug.h>
#include <linux/bug.h>
#include <linux/kernel.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/string.h>
#include <linux/uaccess.h>
#include <linux/uaccess.h>
...
@@ -1128,6 +1129,25 @@ void bitmap_copy_le(unsigned long *dst, const unsigned long *src, unsigned int n
...
@@ -1128,6 +1129,25 @@ void bitmap_copy_le(unsigned long *dst, const unsigned long *src, unsigned int n
EXPORT_SYMBOL
(
bitmap_copy_le
);
EXPORT_SYMBOL
(
bitmap_copy_le
);
#endif
#endif
unsigned
long
*
bitmap_alloc
(
unsigned
int
nbits
,
gfp_t
flags
)
{
return
kmalloc_array
(
BITS_TO_LONGS
(
nbits
),
sizeof
(
unsigned
long
),
flags
);
}
EXPORT_SYMBOL
(
bitmap_alloc
);
unsigned
long
*
bitmap_zalloc
(
unsigned
int
nbits
,
gfp_t
flags
)
{
return
bitmap_alloc
(
nbits
,
flags
|
__GFP_ZERO
);
}
EXPORT_SYMBOL
(
bitmap_zalloc
);
void
bitmap_free
(
const
unsigned
long
*
bitmap
)
{
kfree
(
bitmap
);
}
EXPORT_SYMBOL
(
bitmap_free
);
#if BITS_PER_LONG == 64
#if BITS_PER_LONG == 64
/**
/**
* bitmap_from_arr32 - copy the contents of u32 array of bits to bitmap
* bitmap_from_arr32 - copy the contents of u32 array of bits to bitmap
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment