diff --git a/lustre/obdfilter/filter_io_26.c b/lustre/obdfilter/filter_io_26.c
index c37c58503d0c291fb776709eb20955e74173b745..58f6bdee60f5b075a336bda1af1879baf1a9608d 100644
--- a/lustre/obdfilter/filter_io_26.c
+++ b/lustre/obdfilter/filter_io_26.c
@@ -371,9 +371,10 @@ int filter_do_bio(struct obd_export *exp, struct inode *inode,
                                 frags++;
                         }
 
-                        /* allocate new bio */
-                        bio = bio_alloc(GFP_NOIO,
-                                        (npages - page_idx) * blocks_per_page);
+                        /* allocate new bio, limited by max BIO size, b=9945 */
+                        bio = bio_alloc(GFP_NOIO, max(BIO_MAX_PAGES,
+                                                      (npages - page_idx) *
+                                                      blocks_per_page));
                         if (bio == NULL) {
                                 CERROR("Can't allocate bio %u*%u = %u pages\n",
                                        (npages - page_idx), blocks_per_page,