diff options
author | Ming Lei <tom.leiming@gmail.com> | 2017-03-16 19:12:24 +0300 |
---|---|---|
committer | Shaohua Li <shli@fb.com> | 2017-03-24 20:41:36 +0300 |
commit | 513e2faa0138462ce014e1b0e226ca45c83bc6c1 (patch) | |
tree | ac65dbf0f670f5e5f5fe807ee055f6bd559c77ac /drivers/md/md.h | |
parent | d8e29fbc3bed181f2653fb89ac8c34e40db39c30 (diff) | |
download | linux-513e2faa0138462ce014e1b0e226ca45c83bc6c1.tar.xz |
md: prepare for managing resync I/O pages in clean way
Now resync I/O use bio's bec table to manage pages,
this way is very hacky, and may not work any more
once multipage bvec is introduced.
So introduce helpers and new data structure for
managing resync I/O pages more cleanly.
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md/md.h')
-rw-r--r-- | drivers/md/md.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/drivers/md/md.h b/drivers/md/md.h index 31d2d70849b6..0418b29945e7 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -723,4 +723,54 @@ static inline void mddev_check_writesame(struct mddev *mddev, struct bio *bio) #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 { + unsigned idx; /* for get/put page from the pool */ + 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]; +} + #endif /* _MD_MD_H */ |