Merge remote-tracking branch 'torvalds/master' into perf/core
[sfrench/cifs-2.6.git] / fs / iomap / buffered-io.c
index 16a1e82e3aeb0dc3dc9b629397b4652e1aa8c5ad..7ffcd7ef33d4f500f9f8e0de2a86aca8e1943aeb 100644 (file)
@@ -278,14 +278,14 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
        if (!is_contig || bio_full(ctx->bio, plen)) {
                gfp_t gfp = mapping_gfp_constraint(page->mapping, GFP_KERNEL);
                gfp_t orig_gfp = gfp;
-               int nr_vecs = (length + PAGE_SIZE - 1) >> PAGE_SHIFT;
+               unsigned int nr_vecs = DIV_ROUND_UP(length, PAGE_SIZE);
 
                if (ctx->bio)
                        submit_bio(ctx->bio);
 
                if (ctx->rac) /* same as readahead_gfp_mask */
                        gfp |= __GFP_NORETRY | __GFP_NOWARN;
-               ctx->bio = bio_alloc(gfp, min(BIO_MAX_PAGES, nr_vecs));
+               ctx->bio = bio_alloc(gfp, bio_max_segs(nr_vecs));
                /*
                 * If the bio_alloc fails, try it again for a single page to
                 * avoid having to deal with partial page reads.  This emulates
@@ -1458,13 +1458,6 @@ iomap_do_writepage(struct page *page, struct writeback_control *wbc, void *data)
                        PF_MEMALLOC))
                goto redirty;
 
-       /*
-        * Given that we do not allow direct reclaim to call us, we should
-        * never be called in a recursive filesystem reclaim context.
-        */
-       if (WARN_ON_ONCE(current->flags & PF_MEMALLOC_NOFS))
-               goto redirty;
-
        /*
         * Is this page beyond the end of the file?
         *