Merge tag 'audit-pr-20190507' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoor...
[sfrench/cifs-2.6.git] / block / bio.c
index e717b303e1fb80f4f2f4a41164f417fb9efc95d9..683cbb40f0516a307f5dea53474f084403498379 100644 (file)
@@ -1,19 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (C) 2001 Jens Axboe <axboe@kernel.dk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public Licens
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-
- *
  */
 #include <linux/mm.h>
 #include <linux/swap.h>
@@ -724,11 +711,6 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
        if (((bio->bi_iter.bi_size + len) >> 9) > queue_max_hw_sectors(q))
                return 0;
 
-       /*
-        * For filesystems with a blocksize smaller than the pagesize
-        * we will often be called with the same page as last time and
-        * a consecutive offset.  Optimize this special case.
-        */
        if (bio->bi_vcnt > 0) {
                bvec = &bio->bi_io_vec[bio->bi_vcnt - 1];
 
@@ -736,9 +718,7 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
                    offset == bvec->bv_offset + bvec->bv_len) {
                        if (put_same_page)
                                put_page(page);
- bvec_merge:
                        bvec->bv_len += len;
-                       bio->bi_iter.bi_size += len;
                        goto done;
                }
 
@@ -750,8 +730,10 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
                        return 0;
 
                if (page_is_mergeable(bvec, page, len, offset, false) &&
-                               can_add_page_to_seg(q, bvec, page, len, offset))
-                       goto bvec_merge;
+                   can_add_page_to_seg(q, bvec, page, len, offset)) {
+                       bvec->bv_len += len;
+                       goto done;
+               }
        }
 
        if (bio_full(bio))
@@ -760,18 +742,13 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
        if (bio->bi_phys_segments >= queue_max_segments(q))
                return 0;
 
-       /*
-        * setup the new entry, we might clear it again later if we
-        * cannot add the page
-        */
        bvec = &bio->bi_io_vec[bio->bi_vcnt];
        bvec->bv_page = page;
        bvec->bv_len = len;
        bvec->bv_offset = offset;
        bio->bi_vcnt++;
-       bio->bi_iter.bi_size += len;
-
  done:
+       bio->bi_iter.bi_size += len;
        bio->bi_phys_segments = bio->bi_vcnt;
        bio_set_flag(bio, BIO_SEG_VALID);
        return len;