linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Mike Snitzer <snitzer@redhat.com>,
	Christoph Hellwig <hch@lst.de>, Xiao Ni <xni@redhat.com>,
	Mariusz Dabrowski <mariusz.dabrowski@intel.com>,
	Rui Salvaterra <rsalvaterra@gmail.com>,
	Ming Lei <ming.lei@redhat.com>, Jens Axboe <axboe@kernel.dk>,
	Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Subject: [PATCH 4.19 53/55] block: cleanup __blkdev_issue_discard()
Date: Thu, 30 Jan 2020 19:39:34 +0100	[thread overview]
Message-ID: <20200130183618.023559040@linuxfoundation.org> (raw)
In-Reply-To: <20200130183608.563083888@linuxfoundation.org>

From: Ming Lei <ming.lei@redhat.com>

commit ba5d73851e71847ba7f7f4c27a1a6e1f5ab91c79 upstream.

Cleanup __blkdev_issue_discard() a bit:

- remove local variable of 'end_sect'
- remove code block of 'fail'

Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Xiao Ni <xni@redhat.com>
Cc: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Tested-by: Rui Salvaterra <rsalvaterra@gmail.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 block/blk-lib.c |   23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -52,15 +52,12 @@ int __blkdev_issue_discard(struct block_
 	if ((sector | nr_sects) & bs_mask)
 		return -EINVAL;
 
-	while (nr_sects) {
-		unsigned int req_sects = nr_sects;
-		sector_t end_sect;
-
-		if (!req_sects)
-			goto fail;
-		req_sects = min(req_sects, bio_allowed_max_sectors(q));
+	if (!nr_sects)
+		return -EINVAL;
 
-		end_sect = sector + req_sects;
+	while (nr_sects) {
+		unsigned int req_sects = min_t(unsigned int, nr_sects,
+				bio_allowed_max_sectors(q));
 
 		bio = next_bio(bio, 0, gfp_mask);
 		bio->bi_iter.bi_sector = sector;
@@ -68,8 +65,8 @@ int __blkdev_issue_discard(struct block_
 		bio_set_op_attrs(bio, op, 0);
 
 		bio->bi_iter.bi_size = req_sects << 9;
+		sector += req_sects;
 		nr_sects -= req_sects;
-		sector = end_sect;
 
 		/*
 		 * We can loop for a long time in here, if someone does
@@ -82,14 +79,6 @@ int __blkdev_issue_discard(struct block_
 
 	*biop = bio;
 	return 0;
-
-fail:
-	if (bio) {
-		submit_bio_wait(bio);
-		bio_put(bio);
-	}
-	*biop = NULL;
-	return -EOPNOTSUPP;
 }
 EXPORT_SYMBOL(__blkdev_issue_discard);
 



  parent reply	other threads:[~2020-01-30 18:49 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-30 18:38 [PATCH 4.19 00/55] 4.19.101-stable review Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 01/55] orinoco_usb: fix interface sanity check Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 02/55] rsi_91x_usb: " Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 03/55] usb: dwc3: pci: add ID for the Intel Comet Lake -V variant Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 04/55] USB: serial: ir-usb: add missing endpoint sanity check Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 05/55] USB: serial: ir-usb: fix link-speed handling Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 06/55] USB: serial: ir-usb: fix IrLAP framing Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 07/55] usb: dwc3: turn off VBUS when leaving host mode Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 08/55] staging: most: net: fix buffer overflow Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 09/55] staging: wlan-ng: ensure error return is actually returned Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 10/55] staging: vt6656: correct packet types for CTS protect, mode Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 11/55] staging: vt6656: use NULLFUCTION stack on mac80211 Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 12/55] staging: vt6656: Fix false Tx excessive retries reporting Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 13/55] serial: 8250_bcm2835aux: Fix line mismatch on driver unbind Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 14/55] component: do not dereference opaque pointer in debugfs Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 15/55] mei: me: add comet point (lake) H device ids Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 16/55] iio: st_gyro: Correct data for LSM9DS0 gyro Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 17/55] crypto: chelsio - fix writing tfm flags to wrong place Greg Kroah-Hartman
2020-01-30 18:38 ` [PATCH 4.19 18/55] cifs: Fix memory allocation in __smb2_handle_cancelled_cmd() Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 19/55] ath9k: fix storage endpoint lookup Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 20/55] brcmfmac: fix interface sanity check Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 21/55] rtl8xxxu: " Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 22/55] zd1211rw: fix storage endpoint lookup Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 23/55] net_sched: ematch: reject invalid TCF_EM_SIMPLE Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 24/55] net_sched: fix ops->bind_class() implementations Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 25/55] HID: multitouch: Add LG MELF0410 I2C touchscreen support Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 26/55] arc: eznps: fix allmodconfig kconfig warning Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 27/55] HID: Add quirk for Xin-Mo Dual Controller Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 28/55] HID: ite: Add USB id match for Acer SW5-012 keyboard dock Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 29/55] HID: Add quirk for incorrect input length on Lenovo Y720 Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 30/55] drivers/hid/hid-multitouch.c: fix a possible null pointer access Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 31/55] phy: qcom-qmp: Increase PHY ready timeout Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 32/55] phy: cpcap-usb: Prevent USB line glitches from waking up modem Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 33/55] watchdog: max77620_wdt: fix potential build errors Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 34/55] watchdog: rn5t618_wdt: fix module aliases Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 35/55] spi: spi-dw: Add lock protect dw_spi rx/tx to prevent concurrent calls Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 36/55] drivers/net/b44: Change to non-atomic bit operations on pwol_mask Greg Kroah-Hartman
2020-01-31 12:57   ` Pavel Machek
2020-01-31 13:45     ` David Laight
2020-01-31 14:03     ` Peter Zijlstra
2020-01-31 21:44     ` Luck, Tony
2020-01-30 18:39 ` [PATCH 4.19 37/55] net: wan: sdla: Fix cast from pointer to integer of different size Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 38/55] gpio: max77620: Add missing dependency on GPIOLIB_IRQCHIP Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 39/55] atm: eni: fix uninitialized variable warning Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 40/55] HID: steam: Fix input device disappearing Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 41/55] platform/x86: dell-laptop: disable kbd backlight on Inspiron 10xx Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 42/55] PCI: Add DMA alias quirk for Intel VCA NTB Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 43/55] iommu/amd: Support multiple PCI DMA aliases in IRQ Remapping Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 44/55] ARM: OMAP2+: SmartReflex: add omap_sr_pdata definition Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 45/55] usb-storage: Disable UAS on JMicron SATA enclosure Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 46/55] sched/fair: Add tmp_alone_branch assertion Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 47/55] sched/fair: Fix insertion in rq->leaf_cfs_rq_list Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 48/55] rsi: fix use-after-free on probe errors Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 49/55] rsi: fix memory leak on failed URB submission Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 50/55] rsi: fix non-atomic allocation in completion handler Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 51/55] crypto: af_alg - Use bh_lock_sock in sk_destruct Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 52/55] random: try to actively add entropy rather than passively wait for it Greg Kroah-Hartman
2020-01-30 18:39 ` Greg Kroah-Hartman [this message]
2020-01-30 18:39 ` [PATCH 4.19 54/55] block: fix 32 bit overflow in __blkdev_issue_discard() Greg Kroah-Hartman
2020-01-30 18:39 ` [PATCH 4.19 55/55] KVM: arm64: Write arch.mdcr_el2 changes since last vcpu_load on VHE Greg Kroah-Hartman
2020-01-31  4:40 ` [PATCH 4.19 00/55] 4.19.101-stable review shuah
2020-01-31 11:03 ` Jon Hunter
2020-01-31 13:12 ` Pavel Machek
2020-01-31 21:30   ` Greg Kroah-Hartman
2020-01-31 14:40 ` Naresh Kamboju
2020-01-31 17:32 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200130183618.023559040@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=khlebnikov@yandex-team.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mariusz.dabrowski@intel.com \
    --cc=ming.lei@redhat.com \
    --cc=rsalvaterra@gmail.com \
    --cc=snitzer@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=xni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).