[Devel] [PATCH rh7 5/5] ploop: Kill __dio_io_page()
Kirill Tkhai
ktkhai at virtuozzo.com
Wed Jul 3 19:53:08 MSK 2019
As now clearly seen, functions dio_make_io() and
__dio_io_page() are identical, so let's stop
to hate a reader and remove the duplicate code.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/block/ploop/io_direct.c | 92 +--------------------------------------
1 file changed, 3 insertions(+), 89 deletions(-)
diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
index 3679f8b68cb6..abee1b2ae15c 100644
--- a/drivers/block/ploop/io_direct.c
+++ b/drivers/block/ploop/io_direct.c
@@ -1298,94 +1298,6 @@ static int dio_alloc_sync(struct ploop_io * io, loff_t pos, loff_t len)
return err;
}
-static int
-__dio_io_page(struct ploop_io *io, unsigned long rw, struct page *page,
- sector_t sec, bio_end_io_t *bi_end_io, void *bi_private)
-{
- struct bio_list bl = BIO_EMPTY_LIST;
- struct bio * bio;
- unsigned int len;
- struct extent_map * em;
- sector_t nsec;
- int nr_bios = 0;
- int err;
- int off;
-
- bio = NULL;
- em = NULL;
- off = 0;
-
- len = PAGE_SIZE;
-
- while (len > 0) {
- int copy;
-
- if (!em || sec >= em->end) {
- if (em)
- ploop_extent_put(em);
- em = extent_lookup_create(io, sec, len>>9);
- if (IS_ERR(em))
- goto out_em_err;
- }
-
- nsec = dio_isec_to_phys(em, sec);
-
- if (bio == NULL ||
- bio->bi_sector + (bio->bi_size>>9) != nsec) {
-flush_bio:
- bio = bio_alloc(GFP_NOFS, 32);
- if (bio == NULL)
- goto enomem;
- bio_list_add(&bl, bio);
- bio->bi_bdev = io->files.bdev;
- bio->bi_sector = nsec;
- }
-
- copy = len;
- if (copy > ((em->end - sec) << 9))
- copy = (em->end - sec) << 9;
- if (bio_add_page(bio, page, copy, off) != copy) {
- /* Oops. */
- goto flush_bio;
- }
-
- off += copy;
- len -= copy;
- sec += copy >> 9;
- }
-
- if (em)
- ploop_extent_put(em);
-
- while (bl.head) {
- struct bio * b = bl.head;
- bl.head = b->bi_next;
-
- b->bi_next = NULL;
- b->bi_end_io = bi_end_io;
- b->bi_private = bi_private;
- nr_bios++;
- submit_bio(rw, b);
- }
-
- return nr_bios;
-
-enomem:
- err = -ENOMEM;
- goto out;
-
-out_em_err:
- err = PTR_ERR(em);
-out:
- while (bl.head) {
- struct bio * b = bl.head;
- bl.head = b->bi_next;
- b->bi_next = NULL;
- bio_put(b);
- }
- return err;
-}
-
static void
dio_io_page(struct ploop_io * io, unsigned long rw,
struct ploop_request * preq, struct page * page,
@@ -1403,7 +1315,9 @@ dio_io_page(struct ploop_io * io, unsigned long rw,
if (rw & REQ_WRITE)
ploop_prepare_tracker(preq, sec);
- nr_bios = __dio_io_page(io, rw, page, sec, dio_endio_async, preq);
+ nr_bios = dio_make_io(io, rw, page, PAGE_SIZE, 0, sec,
+ dio_endio_async, preq);
+
if (nr_bios < 0) {
/* Just for uniformity -- make the counter 1 */
ploop_prepare_io_request(preq);
More information about the Devel
mailing list