Commit 6942348d authored by Mikulas Patocka's avatar Mikulas Patocka
Browse files

dm: remove useless test in alloc_multiple_bios



The test gfp_flag & GFP_NOWAIT was always true, because both GFP_NOIO and
GFP_NOWAIT include the flag __GFP_KSWAPD_RECLAIM. Luckily, this oversight
didn't result in any harm; the loop always started with "try = 0".

This patch removes the faulty test and explicitly starts the loop with
"try = 0" (so that we don't hold the mutex in the first iteration).

Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
parent c3a1f2ef
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -1479,12 +1479,12 @@ static void setup_split_accounting(struct clone_info *ci, unsigned int len)

static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci,
				struct dm_target *ti, unsigned int num_bios,
				unsigned *len, gfp_t gfp_flag)
				unsigned *len)
{
	struct bio *bio;
	int try = (gfp_flag & GFP_NOWAIT) ? 0 : 1;
	int try;

	for (; try < 2; try++) {
	for (try = 0; try < 2; try++) {
		int bio_nr;

		if (try && num_bios > 1)
@@ -1508,8 +1508,7 @@ static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci,
}

static unsigned int __send_duplicate_bios(struct clone_info *ci, struct dm_target *ti,
					  unsigned int num_bios, unsigned int *len,
					  gfp_t gfp_flag)
					  unsigned int num_bios, unsigned int *len)
{
	struct bio_list blist = BIO_EMPTY_LIST;
	struct bio *clone;
@@ -1526,7 +1525,7 @@ static unsigned int __send_duplicate_bios(struct clone_info *ci, struct dm_targe
	 * Using alloc_multiple_bios(), even if num_bios is 1, to consistently
	 * support allocating using GFP_NOWAIT with GFP_NOIO fallback.
	 */
	alloc_multiple_bios(&blist, ci, ti, num_bios, len, gfp_flag);
	alloc_multiple_bios(&blist, ci, ti, num_bios, len);
	while ((clone = bio_list_pop(&blist))) {
		if (num_bios > 1)
			dm_tio_set_flag(clone_to_tio(clone), DM_TIO_IS_DUPLICATE_BIO);
@@ -1564,7 +1563,7 @@ static void __send_empty_flush(struct clone_info *ci)

			atomic_add(ti->num_flush_bios, &ci->io->io_count);
			bios = __send_duplicate_bios(ci, ti, ti->num_flush_bios,
						     NULL, GFP_NOWAIT);
						     NULL);
			atomic_sub(ti->num_flush_bios - bios, &ci->io->io_count);
		}
	} else {
@@ -1612,7 +1611,7 @@ static void __send_abnormal_io(struct clone_info *ci, struct dm_target *ti,
		    __max_io_len(ti, ci->sector, max_granularity, max_sectors));

	atomic_add(num_bios, &ci->io->io_count);
	bios = __send_duplicate_bios(ci, ti, num_bios, &len, GFP_NOIO);
	bios = __send_duplicate_bios(ci, ti, num_bios, &len);
	/*
	 * alloc_io() takes one extra reference for submission, so the
	 * reference won't reach 0 without the following (+1) subtraction
@@ -1849,7 +1848,7 @@ static blk_status_t __send_zone_reset_all_emulated(struct clone_info *ci,
			 * not go crazy with the clone allocation.
			 */
			alloc_multiple_bios(&blist, ci, ti, min(nr_reset, 32),
					    NULL, GFP_NOIO);
					    NULL);
		}

		/* Get a clone and change it to a regular reset operation. */
@@ -1881,7 +1880,7 @@ static void __send_zone_reset_all_native(struct clone_info *ci,
	unsigned int bios;

	atomic_add(1, &ci->io->io_count);
	bios = __send_duplicate_bios(ci, ti, 1, NULL, GFP_NOIO);
	bios = __send_duplicate_bios(ci, ti, 1, NULL);
	atomic_sub(1 - bios, &ci->io->io_count);

	ci->sector_count = 0;