All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	linux-block@vger.kernel.org, linux-mtd@lists.infradead.org,
	linux-scsi@vger.kernel.org
Subject: [PATCH 1/5] mtd_blkdevs: remove the sector out of range check in do_blktrans_request
Date: Fri, 26 Nov 2021 13:17:58 +0100	[thread overview]
Message-ID: <20211126121802.2090656-2-hch@lst.de> (raw)
In-Reply-To: <20211126121802.2090656-1-hch@lst.de>

The block layer already performs this check, no need to duplicate it in
the driver.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/mtd_blkdevs.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 66f81d42fe778..113f86df76038 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -54,17 +54,11 @@ static blk_status_t do_blktrans_request(struct mtd_blktrans_ops *tr,
 	block = blk_rq_pos(req) << 9 >> tr->blkshift;
 	nsect = blk_rq_cur_bytes(req) >> tr->blkshift;
 
-	if (req_op(req) == REQ_OP_FLUSH) {
+	switch (req_op(req)) {
+	case REQ_OP_FLUSH:
 		if (tr->flush(dev))
 			return BLK_STS_IOERR;
 		return BLK_STS_OK;
-	}
-
-	if (blk_rq_pos(req) + blk_rq_cur_sectors(req) >
-	    get_capacity(req->rq_disk))
-		return BLK_STS_IOERR;
-
-	switch (req_op(req)) {
 	case REQ_OP_DISCARD:
 		if (tr->discard(dev, block, nsect))
 			return BLK_STS_IOERR;
-- 
2.30.2


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	linux-block@vger.kernel.org, linux-mtd@lists.infradead.org,
	linux-scsi@vger.kernel.org
Subject: [PATCH 1/5] mtd_blkdevs: remove the sector out of range check in do_blktrans_request
Date: Fri, 26 Nov 2021 13:17:58 +0100	[thread overview]
Message-ID: <20211126121802.2090656-2-hch@lst.de> (raw)
In-Reply-To: <20211126121802.2090656-1-hch@lst.de>

The block layer already performs this check, no need to duplicate it in
the driver.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/mtd_blkdevs.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 66f81d42fe778..113f86df76038 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -54,17 +54,11 @@ static blk_status_t do_blktrans_request(struct mtd_blktrans_ops *tr,
 	block = blk_rq_pos(req) << 9 >> tr->blkshift;
 	nsect = blk_rq_cur_bytes(req) >> tr->blkshift;
 
-	if (req_op(req) == REQ_OP_FLUSH) {
+	switch (req_op(req)) {
+	case REQ_OP_FLUSH:
 		if (tr->flush(dev))
 			return BLK_STS_IOERR;
 		return BLK_STS_OK;
-	}
-
-	if (blk_rq_pos(req) + blk_rq_cur_sectors(req) >
-	    get_capacity(req->rq_disk))
-		return BLK_STS_IOERR;
-
-	switch (req_op(req)) {
 	case REQ_OP_DISCARD:
 		if (tr->discard(dev, block, nsect))
 			return BLK_STS_IOERR;
-- 
2.30.2


  reply	other threads:[~2021-11-26 12:30 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-26 12:17 remove ->rq_disk v2 Christoph Hellwig
2021-11-26 12:17 ` Christoph Hellwig
2021-11-26 12:17 ` Christoph Hellwig [this message]
2021-11-26 12:17   ` [PATCH 1/5] mtd_blkdevs: remove the sector out of range check in do_blktrans_request Christoph Hellwig
2021-11-26 12:17 ` [PATCH 2/5] block: don't check ->rq_disk in merges Christoph Hellwig
2021-11-26 12:17   ` Christoph Hellwig
2021-11-26 12:18 ` [PATCH 3/5] block: remove the ->rq_disk field in struct request Christoph Hellwig
2021-11-26 12:18   ` Christoph Hellwig
2021-11-26 12:18 ` [PATCH 4/5] block: remove the gendisk argument to blk_execute_rq Christoph Hellwig
2021-11-26 12:18   ` Christoph Hellwig
2021-11-26 12:18 ` [PATCH 5/5] scsi: remove the gendisk argument to scsi_ioctl Christoph Hellwig
2021-11-26 12:18   ` Christoph Hellwig
2021-11-27 13:40 ` remove ->rq_disk v2 Jens Axboe
2021-11-27 13:40   ` Jens Axboe
2021-11-27 16:35 ` Martin K. Petersen
2021-11-27 16:35   ` Martin K. Petersen
2021-11-27 16:49 ` Jens Axboe
2021-11-27 16:49   ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2021-09-28  5:22 remove ->rq_disk Christoph Hellwig
2021-09-28  5:22 ` [PATCH 1/5] mtd_blkdevs: remove the sector out of range check in do_blktrans_request Christoph Hellwig
2021-09-28  5:22   ` Christoph Hellwig
2021-09-28  8:51   ` Miquel Raynal
2021-09-28  8:51     ` Miquel Raynal

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=20211126121802.2090656-2-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.