watchdog/core: Rename some softlockup_* functions
[linux/fpc-iii.git] / drivers / md / raid1-10.c
blob9f2670b45f31ae8b99b09f33309bf31c6f704c7c
1 /* Maximum size of each resync request */
2 #define RESYNC_BLOCK_SIZE (64*1024)
3 #define RESYNC_PAGES ((RESYNC_BLOCK_SIZE + PAGE_SIZE-1) / PAGE_SIZE)
5 /* for managing resync I/O pages */
6 struct resync_pages {
7 void *raid_bio;
8 struct page *pages[RESYNC_PAGES];
9 };
11 static inline int resync_alloc_pages(struct resync_pages *rp,
12 gfp_t gfp_flags)
14 int i;
16 for (i = 0; i < RESYNC_PAGES; i++) {
17 rp->pages[i] = alloc_page(gfp_flags);
18 if (!rp->pages[i])
19 goto out_free;
22 return 0;
24 out_free:
25 while (--i >= 0)
26 put_page(rp->pages[i]);
27 return -ENOMEM;
30 static inline void resync_free_pages(struct resync_pages *rp)
32 int i;
34 for (i = 0; i < RESYNC_PAGES; i++)
35 put_page(rp->pages[i]);
38 static inline void resync_get_all_pages(struct resync_pages *rp)
40 int i;
42 for (i = 0; i < RESYNC_PAGES; i++)
43 get_page(rp->pages[i]);
46 static inline struct page *resync_fetch_page(struct resync_pages *rp,
47 unsigned idx)
49 if (WARN_ON_ONCE(idx >= RESYNC_PAGES))
50 return NULL;
51 return rp->pages[idx];
55 * 'strct resync_pages' stores actual pages used for doing the resync
56 * IO, and it is per-bio, so make .bi_private points to it.
58 static inline struct resync_pages *get_resync_pages(struct bio *bio)
60 return bio->bi_private;
63 /* generally called after bio_reset() for reseting bvec */
64 static void md_bio_reset_resync_pages(struct bio *bio, struct resync_pages *rp,
65 int size)
67 int idx = 0;
69 /* initialize bvec table again */
70 do {
71 struct page *page = resync_fetch_page(rp, idx);
72 int len = min_t(int, size, PAGE_SIZE);
75 * won't fail because the vec table is big
76 * enough to hold all these pages
78 bio_add_page(bio, page, len, 0);
79 size -= len;
80 } while (idx++ < RESYNC_PAGES && size > 0);