Commit ed00aabd authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe
Browse files

block: rename generic_make_request to submit_bio_noacct



generic_make_request has always been very confusingly misnamed, so rename
it to submit_bio_noacct to make it clear that it is submit_bio minus
accounting and a few checks.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent c62b37d9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1036,7 +1036,7 @@ Now the generic block layer performs partition-remapping early and thus
provides drivers with a sector number relative to whole device, rather than
having to take partition number into account in order to arrive at the true
sector number. The routine blk_partition_remap() is invoked by
generic_make_request even before invoking the queue specific ->submit_bio,
submit_bio_noacct even before invoking the queue specific ->submit_bio,
so the i/o scheduler also gets to operate on whole disk sector numbers. This
should typically not require changes to block drivers, it just never gets
to invoke its own partition sector offset calculations since all bios
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ Available fault injection capabilities

  injects disk IO errors on devices permitted by setting
  /sys/block/<device>/make-it-fail or
  /sys/block/<device>/<partition>/make-it-fail. (generic_make_request())
  /sys/block/<device>/<partition>/make-it-fail. (submit_bio_noacct())

- fail_mmc_request

+2 −2
Original line number Diff line number Diff line
@@ -1453,7 +1453,7 @@ function-trace, we get a much larger output::
   => __blk_run_queue_uncond
   => __blk_run_queue
   => blk_queue_bio
   => generic_make_request
   => submit_bio_noacct
   => submit_bio
   => submit_bh
   => __ext3_get_inode_loc
@@ -1738,7 +1738,7 @@ tracers.
   => __blk_run_queue_uncond
   => __blk_run_queue
   => blk_queue_bio
   => generic_make_request
   => submit_bio_noacct
   => submit_bio
   => submit_bh
   => ext3_bread
+7 −7
Original line number Diff line number Diff line
@@ -358,7 +358,7 @@ static void bio_alloc_rescue(struct work_struct *work)
		if (!bio)
			break;

		generic_make_request(bio);
		submit_bio_noacct(bio);
	}
}

@@ -416,19 +416,19 @@ static void punt_bios_to_rescuer(struct bio_set *bs)
 *   submit the previously allocated bio for IO before attempting to allocate
 *   a new one. Failure to do so can cause deadlocks under memory pressure.
 *
 *   Note that when running under generic_make_request() (i.e. any block
 *   Note that when running under submit_bio_noacct() (i.e. any block
 *   driver), bios are not submitted until after you return - see the code in
 *   generic_make_request() that converts recursion into iteration, to prevent
 *   submit_bio_noacct() that converts recursion into iteration, to prevent
 *   stack overflows.
 *
 *   This would normally mean allocating multiple bios under
 *   generic_make_request() would be susceptible to deadlocks, but we have
 *   submit_bio_noacct() would be susceptible to deadlocks, but we have
 *   deadlock avoidance code that resubmits any blocked bios from a rescuer
 *   thread.
 *
 *   However, we do not guarantee forward progress for allocations from other
 *   mempools. Doing multiple allocations from the same mempool under
 *   generic_make_request() should be avoided - instead, use bio_set's front_pad
 *   submit_bio_noacct() should be avoided - instead, use bio_set's front_pad
 *   for per bio allocations.
 *
 *   RETURNS:
@@ -457,14 +457,14 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, unsigned int nr_iovecs,
				 nr_iovecs > 0))
			return NULL;
		/*
		 * generic_make_request() converts recursion to iteration; this
		 * submit_bio_noacct() converts recursion to iteration; this
		 * means if we're running beneath it, any bios we allocate and
		 * submit will not be submitted (and thus freed) until after we
		 * return.
		 *
		 * This exposes us to a potential deadlock if we allocate
		 * multiple bios from the same bio_set() while running
		 * underneath generic_make_request(). If we were to allocate
		 * underneath submit_bio_noacct(). If we were to allocate
		 * multiple bios (say a stacking block driver that was splitting
		 * bios), we would deadlock if we exhausted the mempool's
		 * reserve.
+15 −17
Original line number Diff line number Diff line
@@ -956,8 +956,7 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q,
	return BLK_STS_OK;
}

static noinline_for_stack bool
generic_make_request_checks(struct bio *bio)
static noinline_for_stack bool submit_bio_checks(struct bio *bio)
{
	struct request_queue *q = bio->bi_disk->queue;
	blk_status_t status = BLK_STS_IOERR;
@@ -985,9 +984,8 @@ generic_make_request_checks(struct bio *bio)
	}

	/*
	 * Filter flush bio's early so that make_request based
	 * drivers without flush support don't have to worry
	 * about them.
	 * Filter flush bio's early so that bio based drivers without flush
	 * support don't have to worry about them.
	 */
	if (op_is_flush(bio->bi_opf) &&
	    !test_bit(QUEUE_FLAG_WC, &q->queue_flags)) {
@@ -1072,7 +1070,7 @@ end_io:
	return false;
}

static blk_qc_t do_make_request(struct bio *bio)
static blk_qc_t __submit_bio(struct bio *bio)
{
	struct gendisk *disk = bio->bi_disk;
	blk_qc_t ret = BLK_QC_T_NONE;
@@ -1087,7 +1085,7 @@ static blk_qc_t do_make_request(struct bio *bio)
}

/**
 * generic_make_request - re-submit a bio to the block device layer for I/O
 * submit_bio_noacct - re-submit a bio to the block device layer for I/O
 * @bio:  The bio describing the location in memory and on the device.
 *
 * This is a version of submit_bio() that shall only be used for I/O that is
@@ -1095,7 +1093,7 @@ static blk_qc_t do_make_request(struct bio *bio)
 * systems and other upper level users of the block layer should use
 * submit_bio() instead.
 */
blk_qc_t generic_make_request(struct bio *bio)
blk_qc_t submit_bio_noacct(struct bio *bio)
{
	/*
	 * bio_list_on_stack[0] contains bios submitted by the current
@@ -1106,7 +1104,7 @@ blk_qc_t generic_make_request(struct bio *bio)
	struct bio_list bio_list_on_stack[2];
	blk_qc_t ret = BLK_QC_T_NONE;

	if (!generic_make_request_checks(bio))
	if (!submit_bio_checks(bio))
		goto out;

	/*
@@ -1114,7 +1112,7 @@ blk_qc_t generic_make_request(struct bio *bio)
	 * stack usage with stacked devices could be a problem.  So use
	 * current->bio_list to keep a list of requests submited by a
	 * ->submit_bio method.  current->bio_list is also used as a
	 * flag to say if generic_make_request is currently active in this
	 * flag to say if submit_bio_noacct is currently active in this
	 * task or not.  If it is NULL, then no make_request is active.  If
	 * it is non-NULL, then a make_request is active, and new requests
	 * should be added at the tail
@@ -1132,7 +1130,7 @@ blk_qc_t generic_make_request(struct bio *bio)
	 * we assign bio_list to a pointer to the bio_list_on_stack,
	 * thus initialising the bio_list of new bios to be
	 * added.  ->submit_bio() may indeed add some more bios
	 * through a recursive call to generic_make_request.  If it
	 * through a recursive call to submit_bio_noacct.  If it
	 * did, we find a non-NULL value in bio_list and re-enter the loop
	 * from the top.  In this case we really did just take the bio
	 * of the top of the list (no pretending) and so remove it from
@@ -1150,7 +1148,7 @@ blk_qc_t generic_make_request(struct bio *bio)
			/* Create a fresh bio_list for all subordinate requests */
			bio_list_on_stack[1] = bio_list_on_stack[0];
			bio_list_init(&bio_list_on_stack[0]);
			ret = do_make_request(bio);
			ret = __submit_bio(bio);

			/* sort new bios into those for a lower level
			 * and those for the same level
@@ -1174,13 +1172,13 @@ blk_qc_t generic_make_request(struct bio *bio)
out:
	return ret;
}
EXPORT_SYMBOL(generic_make_request);
EXPORT_SYMBOL(submit_bio_noacct);

/**
 * direct_make_request - hand a buffer directly to its device driver for I/O
 * @bio:  The bio describing the location in memory and on the device.
 *
 * This function behaves like generic_make_request(), but does not protect
 * This function behaves like submit_bio_noacct(), but does not protect
 * against recursion.  Must only be used if the called driver is known
 * to be blk-mq based.
 */
@@ -1192,7 +1190,7 @@ blk_qc_t direct_make_request(struct bio *bio)
		bio_io_error(bio);
		return BLK_QC_T_NONE;
	}
	if (!generic_make_request_checks(bio))
	if (!submit_bio_checks(bio))
		return BLK_QC_T_NONE;
	if (unlikely(bio_queue_enter(bio)))
		return BLK_QC_T_NONE;
@@ -1263,13 +1261,13 @@ blk_qc_t submit_bio(struct bio *bio)
		blk_qc_t ret;

		psi_memstall_enter(&pflags);
		ret = generic_make_request(bio);
		ret = submit_bio_noacct(bio);
		psi_memstall_leave(&pflags);

		return ret;
	}

	return generic_make_request(bio);
	return submit_bio_noacct(bio);
}
EXPORT_SYMBOL(submit_bio);

Loading