btrfs: get fs_info from eb in btrfs_check_leaf_full
[sfrench/cifs-2.6.git] / fs / buffer.c
index 48318fb74938a458184c7b77598994915474ade7..ce357602f471dbe1ebf7f998af50d69d5884ba4a 100644 (file)
@@ -3027,13 +3027,23 @@ void guard_bio_eod(int op, struct bio *bio)
        /* Uhhuh. We've got a bio that straddles the device size! */
        truncated_bytes = bio->bi_iter.bi_size - (maxsector << 9);
 
+       /*
+        * The bio contains more than one segment which spans EOD, just return
+        * and let IO layer turn it into an EIO
+        */
+       if (truncated_bytes > bvec->bv_len)
+               return;
+
        /* Truncate the bio.. */
        bio->bi_iter.bi_size -= truncated_bytes;
        bvec->bv_len -= truncated_bytes;
 
        /* ..and clear the end of the buffer for reads */
        if (op == REQ_OP_READ) {
-               zero_user(bvec->bv_page, bvec->bv_offset + bvec->bv_len,
+               struct bio_vec bv;
+
+               mp_bvec_last_segment(bvec, &bv);
+               zero_user(bv.bv_page, bv.bv_offset + bv.bv_len,
                                truncated_bytes);
        }
 }