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 */
8 struct page
*pages
[RESYNC_PAGES
];
11 static inline int resync_alloc_pages(struct resync_pages
*rp
,
16 for (i
= 0; i
< RESYNC_PAGES
; i
++) {
17 rp
->pages
[i
] = alloc_page(gfp_flags
);
26 put_page(rp
->pages
[i
]);
30 static inline void resync_free_pages(struct resync_pages
*rp
)
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
)
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
,
49 if (WARN_ON_ONCE(idx
>= RESYNC_PAGES
))
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
,
69 /* initialize bvec table again */
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);
80 } while (idx
++ < RESYNC_PAGES
&& size
> 0);