summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-09-25 13:38:54 -0700
committerKent Overstreet <kmo@daterainc.com>2014-06-17 18:26:02 -0700
commite4bcc6aaeb804dfe48ac0ee836802e7c6d32542e (patch)
tree93779d4087d4c1accced42116e94f84cd5b20452
parentc013b1438060c77c103358041a775f3fe64b9daf (diff)
foo
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
-rw-r--r--drivers/block/pktcdvd.c10
-rw-r--r--fs/logfs/dev_bdev.c56
2 files changed, 27 insertions, 39 deletions
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 4a5b1298c131..0b4e59ccaae3 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -1295,7 +1295,6 @@ try_next_bio:
static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt)
{
int f;
- struct bio_vec *bvec = pkt->w_bio->bi_io_vec;
bio_reset(pkt->w_bio);
pkt->w_bio->bi_iter.bi_sector = pkt->sector;
@@ -1305,9 +1304,10 @@ static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt)
/* XXX: locking? */
for (f = 0; f < pkt->frames; f++) {
- bvec[f].bv_page = pkt->pages[(f * CD_FRAMESIZE) / PAGE_SIZE];
- bvec[f].bv_offset = (f * CD_FRAMESIZE) % PAGE_SIZE;
- if (!bio_add_page(pkt->w_bio, bvec[f].bv_page, CD_FRAMESIZE, bvec[f].bv_offset))
+ if (bio_add_page(pkt->w_bio,
+ pkt->pages[(f * CD_FRAMESIZE) / PAGE_SIZE],
+ CD_FRAMESIZE,
+ (f * CD_FRAMESIZE) % PAGE_SIZE) != CD_FRAMESIZE)
BUG();
}
pkt_dbg(2, pd, "vcnt=%d\n", pkt->w_bio->bi_vcnt);
@@ -1325,7 +1325,7 @@ static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt)
pkt->write_size, (unsigned long long)pkt->sector);
if (test_bit(PACKET_MERGE_SEGS, &pd->flags) || (pkt->write_size < pkt->frames)) {
- pkt_make_local_copy(pkt, bvec);
+ pkt_make_local_copy(pkt, pkt->w_bio->bi_io_vec);
pkt->cache_valid = 1;
} else {
pkt->cache_valid = 0;
diff --git a/fs/logfs/dev_bdev.c b/fs/logfs/dev_bdev.c
index 05253de88b6f..492d2e5d55a7 100644
--- a/fs/logfs/dev_bdev.c
+++ b/fs/logfs/dev_bdev.c
@@ -80,50 +80,38 @@ static int __bdev_writeseg(struct super_block *sb, u64 ofs, pgoff_t index,
struct address_space *mapping = super->s_mapping_inode->i_mapping;
struct bio *bio;
struct page *page;
- unsigned int max_pages;
- int i;
+ int i = 0;
- max_pages = min(nr_pages, (size_t) BIO_MAX_PAGES);
+ bio = bio_alloc(GFP_NOFS,
+ min(nr_pages - i, (size_t) BIO_MAX_PAGES));
- bio = bio_alloc(GFP_NOFS, max_pages);
- BUG_ON(!bio);
+ bio->bi_bdev = super->s_bdev;
+ bio->bi_iter.bi_sector = (ofs + i * PAGE_SIZE) >> 9;
+ bio->bi_private = sb;
+ bio->bi_end_io = writeseg_end_io;
for (i = 0; i < nr_pages; i++) {
- if (i >= max_pages) {
- /* Block layer cannot split bios :( */
- bio->bi_vcnt = i;
- bio->bi_iter.bi_size = i * PAGE_SIZE;
- bio->bi_bdev = super->s_bdev;
- bio->bi_iter.bi_sector = ofs >> 9;
- bio->bi_private = sb;
- bio->bi_end_io = writeseg_end_io;
- atomic_inc(&super->s_pending_writes);
- submit_bio(WRITE, bio);
-
- ofs += i * PAGE_SIZE;
- index += i;
- nr_pages -= i;
- i = 0;
-
- bio = bio_alloc(GFP_NOFS, max_pages);
- BUG_ON(!bio);
- }
page = find_lock_page(mapping, index + i);
BUG_ON(!page);
- bio->bi_io_vec[i].bv_page = page;
- bio->bi_io_vec[i].bv_len = PAGE_SIZE;
- bio->bi_io_vec[i].bv_offset = 0;
-
BUG_ON(PageWriteback(page));
set_page_writeback(page);
unlock_page(page);
+retry:
+ if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) {
+ atomic_inc(&super->s_pending_writes);
+ submit_bio(WRITE, bio);
+start:
+ bio = bio_alloc(GFP_NOFS,
+ min(nr_pages - i, (size_t) BIO_MAX_PAGES));
+
+ bio->bi_bdev = super->s_bdev;
+ bio->bi_iter.bi_sector = (ofs + i * PAGE_SIZE) >> 9;
+ bio->bi_private = sb;
+ bio->bi_end_io = writeseg_end_io;
+ goto retry;
+
+ }
}
- bio->bi_vcnt = nr_pages;
- bio->bi_iter.bi_size = nr_pages * PAGE_SIZE;
- bio->bi_bdev = super->s_bdev;
- bio->bi_iter.bi_sector = ofs >> 9;
- bio->bi_private = sb;
- bio->bi_end_io = writeseg_end_io;
atomic_inc(&super->s_pending_writes);
submit_bio(WRITE, bio);
return 0;