Commit 6e1cd5dd authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] loop: loop bio renaming

From: Hugh Dickins <hugh@veritas.com>

Now it's in loop not bio, better rename bio_copy to loop_copy_bio: loop
prefers names that way; and bio_transfer better named loop_transfer_bio.
Rename bio,b to rbh,bio to follow call from loop_get_buffer more easily.
parent ac5c28b4
...@@ -439,21 +439,22 @@ static int loop_end_io_transfer(struct bio *bio, unsigned int bytes_done, int er ...@@ -439,21 +439,22 @@ static int loop_end_io_transfer(struct bio *bio, unsigned int bytes_done, int er
return 0; return 0;
} }
static struct bio *bio_copy(struct bio *bio, int gfp_mask, int copy) static struct bio *loop_copy_bio(struct bio *rbh, int gfp_mask, int copy)
{ {
struct bio *b = bio_alloc(gfp_mask, bio->bi_vcnt); struct bio *bio;
unsigned long flags = 0; /* gcc silly */ unsigned long flags = 0; /* gcc silly */
struct bio_vec *bv; struct bio_vec *bv;
int i; int i;
if (unlikely(!b)) bio = bio_alloc(gfp_mask, rbh->bi_vcnt);
if (!bio)
return NULL; return NULL;
/* /*
* iterate iovec list and alloc pages + copy data * iterate iovec list and alloc pages + copy data
*/ */
__bio_for_each_segment(bv, bio, i, 0) { __bio_for_each_segment(bv, rbh, i, 0) {
struct bio_vec *bbv = &b->bi_io_vec[i]; struct bio_vec *bbv = &bio->bi_io_vec[i];
char *vfrom, *vto; char *vfrom, *vto;
bbv->bv_page = alloc_page(gfp_mask); bbv->bv_page = alloc_page(gfp_mask);
...@@ -490,18 +491,18 @@ static struct bio *bio_copy(struct bio *bio, int gfp_mask, int copy) ...@@ -490,18 +491,18 @@ static struct bio *bio_copy(struct bio *bio, int gfp_mask, int copy)
} }
} }
b->bi_sector = bio->bi_sector; bio->bi_sector = rbh->bi_sector;
b->bi_bdev = bio->bi_bdev; bio->bi_bdev = rbh->bi_bdev;
b->bi_rw = bio->bi_rw; bio->bi_rw = rbh->bi_rw;
b->bi_vcnt = bio->bi_vcnt; bio->bi_vcnt = rbh->bi_vcnt;
b->bi_size = bio->bi_size; bio->bi_size = rbh->bi_size;
return b; return bio;
oom: oom:
while (--i >= 0) while (--i >= 0)
__free_page(b->bi_io_vec[i].bv_page); __free_page(bio->bi_io_vec[i].bv_page);
bio_put(bio); bio_put(bio);
return NULL; return NULL;
...@@ -529,7 +530,8 @@ static struct bio *loop_get_buffer(struct loop_device *lo, struct bio *rbh) ...@@ -529,7 +530,8 @@ static struct bio *loop_get_buffer(struct loop_device *lo, struct bio *rbh)
int flags = current->flags; int flags = current->flags;
current->flags &= ~PF_MEMALLOC; current->flags &= ~PF_MEMALLOC;
bio = bio_copy(rbh, (GFP_ATOMIC & ~__GFP_HIGH) | __GFP_NOWARN, bio = loop_copy_bio(rbh,
(GFP_ATOMIC & ~__GFP_HIGH) | __GFP_NOWARN,
rbh->bi_rw & WRITE); rbh->bi_rw & WRITE);
current->flags = flags; current->flags = flags;
if (bio == NULL) if (bio == NULL)
...@@ -547,9 +549,8 @@ static struct bio *loop_get_buffer(struct loop_device *lo, struct bio *rbh) ...@@ -547,9 +549,8 @@ static struct bio *loop_get_buffer(struct loop_device *lo, struct bio *rbh)
return bio; return bio;
} }
static int static int loop_transfer_bio(struct loop_device *lo,
bio_transfer(struct loop_device *lo, struct bio *to_bio, struct bio *to_bio, struct bio *from_bio)
struct bio *from_bio)
{ {
unsigned long IV = loop_get_iv(lo, from_bio->bi_sector); unsigned long IV = loop_get_iv(lo, from_bio->bi_sector);
struct bio_vec *from_bvec, *to_bvec; struct bio_vec *from_bvec, *to_bvec;
...@@ -614,7 +615,7 @@ static int loop_make_request(request_queue_t *q, struct bio *old_bio) ...@@ -614,7 +615,7 @@ static int loop_make_request(request_queue_t *q, struct bio *old_bio)
new_bio = loop_get_buffer(lo, old_bio); new_bio = loop_get_buffer(lo, old_bio);
IV = loop_get_iv(lo, old_bio->bi_sector); IV = loop_get_iv(lo, old_bio->bi_sector);
if (rw == WRITE) { if (rw == WRITE) {
if (bio_transfer(lo, new_bio, old_bio)) if (loop_transfer_bio(lo, new_bio, old_bio))
goto err; goto err;
} }
...@@ -646,7 +647,7 @@ static inline void loop_handle_bio(struct loop_device *lo, struct bio *bio) ...@@ -646,7 +647,7 @@ static inline void loop_handle_bio(struct loop_device *lo, struct bio *bio)
} else { } else {
struct bio *rbh = bio->bi_private; struct bio *rbh = bio->bi_private;
ret = bio_transfer(lo, bio, rbh); ret = loop_transfer_bio(lo, bio, rbh);
bio_endio(rbh, rbh->bi_size, ret); bio_endio(rbh, rbh->bi_size, ret);
loop_put_buffer(bio); loop_put_buffer(bio);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment