page allocator: replace __alloc_pages_internal() with __alloc_pages_nodemask()
[sfrench/cifs-2.6.git] / fs / bio.c
index 98711647ece49548a94409a99ce4b680ee085ca1..5f80848c320c7a66c6425e75aea21533607134fa 100644 (file)
--- a/fs/bio.c
+++ b/fs/bio.c
 #include <linux/mempool.h>
 #include <linux/workqueue.h>
 #include <linux/blktrace_api.h>
-#include <trace/block.h>
 #include <scsi/sg.h>           /* for struct sg_iovec */
 
-DEFINE_TRACE(block_split);
+#include <trace/events/block.h>
 
 /*
  * Test patch to inline a certain number of bi_io_vec's inside the bio
@@ -359,9 +358,9 @@ static void bio_kmalloc_destructor(struct bio *bio)
  *
  *   If %__GFP_WAIT is set, then bio_alloc will always be able to allocate
  *   a bio. This is due to the mempool guarantees. To make this work, callers
- *   must never allocate more than 1 bio at the time from this pool. Callers
+ *   must never allocate more than 1 bio at a time from this pool. Callers
  *   that need to allocate more than 1 bio must always submit the previously
- *   allocate bio for IO before attempting to allocate a new one. Failure to
+ *   allocated bio for IO before attempting to allocate a new one. Failure to
  *   do so can cause livelocks under memory pressure.
  *
  **/
@@ -499,11 +498,11 @@ int bio_get_nr_vecs(struct block_device *bdev)
        struct request_queue *q = bdev_get_queue(bdev);
        int nr_pages;
 
-       nr_pages = ((q->max_sectors << 9) + PAGE_SIZE - 1) >> PAGE_SHIFT;
-       if (nr_pages > q->max_phys_segments)
-               nr_pages = q->max_phys_segments;
-       if (nr_pages > q->max_hw_segments)
-               nr_pages = q->max_hw_segments;
+       nr_pages = ((queue_max_sectors(q) << 9) + PAGE_SIZE - 1) >> PAGE_SHIFT;
+       if (nr_pages > queue_max_phys_segments(q))
+               nr_pages = queue_max_phys_segments(q);
+       if (nr_pages > queue_max_hw_segments(q))
+               nr_pages = queue_max_hw_segments(q);
 
        return nr_pages;
 }
@@ -562,8 +561,8 @@ static int __bio_add_page(struct request_queue *q, struct bio *bio, struct page
         * make this too complex.
         */
 
-       while (bio->bi_phys_segments >= q->max_phys_segments
-              || bio->bi_phys_segments >= q->max_hw_segments) {
+       while (bio->bi_phys_segments >= queue_max_phys_segments(q)
+              || bio->bi_phys_segments >= queue_max_hw_segments(q)) {
 
                if (retried_segments)
                        return 0;
@@ -634,7 +633,8 @@ static int __bio_add_page(struct request_queue *q, struct bio *bio, struct page
 int bio_add_pc_page(struct request_queue *q, struct bio *bio, struct page *page,
                    unsigned int len, unsigned int offset)
 {
-       return __bio_add_page(q, bio, page, len, offset, q->max_hw_sectors);
+       return __bio_add_page(q, bio, page, len, offset,
+                             queue_max_hw_sectors(q));
 }
 
 /**
@@ -654,7 +654,7 @@ int bio_add_page(struct bio *bio, struct page *page, unsigned int len,
                 unsigned int offset)
 {
        struct request_queue *q = bdev_get_queue(bio->bi_bdev);
-       return __bio_add_page(q, bio, page, len, offset, q->max_sectors);
+       return __bio_add_page(q, bio, page, len, offset, queue_max_sectors(q));
 }
 
 struct bio_map_data {
@@ -721,7 +721,7 @@ static int __bio_copy_iov(struct bio *bio, struct bio_vec *iovecs,
 
                while (bv_len && iov_idx < iov_count) {
                        unsigned int bytes;
-                       char *iov_addr;
+                       char __user *iov_addr;
 
                        bytes = min_t(unsigned int,
                                      iov[iov_idx].iov_len - iov_off, bv_len);
@@ -1201,7 +1201,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
                char *addr = page_address(bvec->bv_page);
                int len = bmd->iovecs[i].bv_len;
 
-               if (read && !err)
+               if (read)
                        memcpy(p, addr, len);
 
                __free_page(bvec->bv_page);
@@ -1490,11 +1490,12 @@ struct bio_pair *bio_split(struct bio *bi, int first_sectors)
 sector_t bio_sector_offset(struct bio *bio, unsigned short index,
                           unsigned int offset)
 {
-       unsigned int sector_sz = queue_hardsect_size(bio->bi_bdev->bd_disk->queue);
+       unsigned int sector_sz;
        struct bio_vec *bv;
        sector_t sectors;
        int i;
 
+       sector_sz = queue_logical_block_size(bio->bi_bdev->bd_disk->queue);
        sectors = 0;
 
        if (index >= bio->bi_idx)