forked from beagleboard/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/…
…git/shli/md Pull MD fixes from Shaohua Li: "This fixes several bugs, three of them are marked for stable: - an initialization issue fixed by Ming - a bio clone race issue fixed by me - an async tx flush issue fixed by Ofer - other cleanups" * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md: MD: fix warnning for UP case md/raid5: add thread_group worker async_tx_issue_pending_all md: simplify code with bio_io_error md/raid1: fix writebehind bio clone md: raid1-10: move raid1/raid10 common code into raid1-10.c md: raid1/raid10: initialize bvec table via bio_add_page() md: remove 'idx' from 'struct resync_pages'
- Loading branch information
Showing
6 changed files
with
115 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* Maximum size of each resync request */ | ||
#define RESYNC_BLOCK_SIZE (64*1024) | ||
#define RESYNC_PAGES ((RESYNC_BLOCK_SIZE + PAGE_SIZE-1) / PAGE_SIZE) | ||
|
||
/* for managing resync I/O pages */ | ||
struct resync_pages { | ||
void *raid_bio; | ||
struct page *pages[RESYNC_PAGES]; | ||
}; | ||
|
||
static inline int resync_alloc_pages(struct resync_pages *rp, | ||
gfp_t gfp_flags) | ||
{ | ||
int i; | ||
|
||
for (i = 0; i < RESYNC_PAGES; i++) { | ||
rp->pages[i] = alloc_page(gfp_flags); | ||
if (!rp->pages[i]) | ||
goto out_free; | ||
} | ||
|
||
return 0; | ||
|
||
out_free: | ||
while (--i >= 0) | ||
put_page(rp->pages[i]); | ||
return -ENOMEM; | ||
} | ||
|
||
static inline void resync_free_pages(struct resync_pages *rp) | ||
{ | ||
int i; | ||
|
||
for (i = 0; i < RESYNC_PAGES; i++) | ||
put_page(rp->pages[i]); | ||
} | ||
|
||
static inline void resync_get_all_pages(struct resync_pages *rp) | ||
{ | ||
int i; | ||
|
||
for (i = 0; i < RESYNC_PAGES; i++) | ||
get_page(rp->pages[i]); | ||
} | ||
|
||
static inline struct page *resync_fetch_page(struct resync_pages *rp, | ||
unsigned idx) | ||
{ | ||
if (WARN_ON_ONCE(idx >= RESYNC_PAGES)) | ||
return NULL; | ||
return rp->pages[idx]; | ||
} | ||
|
||
/* | ||
* 'strct resync_pages' stores actual pages used for doing the resync | ||
* IO, and it is per-bio, so make .bi_private points to it. | ||
*/ | ||
static inline struct resync_pages *get_resync_pages(struct bio *bio) | ||
{ | ||
return bio->bi_private; | ||
} | ||
|
||
/* generally called after bio_reset() for reseting bvec */ | ||
static void md_bio_reset_resync_pages(struct bio *bio, struct resync_pages *rp, | ||
int size) | ||
{ | ||
int idx = 0; | ||
|
||
/* initialize bvec table again */ | ||
do { | ||
struct page *page = resync_fetch_page(rp, idx); | ||
int len = min_t(int, size, PAGE_SIZE); | ||
|
||
/* | ||
* won't fail because the vec table is big | ||
* enough to hold all these pages | ||
*/ | ||
bio_add_page(bio, page, len, 0); | ||
size -= len; | ||
} while (idx++ < RESYNC_PAGES && size > 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.