public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: michaelc@cs.wisc.edu
To: linux-scsi@vger.kernel.org, axboe@fb.com
Cc: Mike Christie <michaelc@cs.wisc.edu>
Subject: [PATCH 1/1] block: don't overwrite max_sectors if user has set it
Date: Fri, 10 Apr 2015 02:08:40 -0500	[thread overview]
Message-ID: <1428649720-14316-1-git-send-email-michaelc@cs.wisc.edu> (raw)

From: Mike Christie <michaelc@cs.wisc.edu>

If the user has set max_sectors in sysfs, but the disk is revalidated
due to it being removable or having write protections and it being
opened, or dm/md claiming it, or something like a scsi rescan, etc,
then we are overwriting the user specified max_sectors value. This patch
only has us set the max_sectors if the new max_hw_sectors is smaller
or if the user has not changed max_sectors.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
 block/blk-settings.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 12600bf..d6c7b0c 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -248,6 +248,10 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
  *    filesystem type requests.  This value can be overridden on a
  *    per-device basis in /sys/block/<device>/queue/max_sectors_kb.
  *    The soft limit can not exceed max_hw_sectors.
+ *
+ *    If this is called as a result of a revalidation then we will only
+ *    override the user specified max_sectors if the new max_hw_sectors is
+ *    smaller.
  **/
 void blk_limits_max_hw_sectors(struct queue_limits *limits, unsigned int max_hw_sectors)
 {
@@ -257,7 +261,11 @@ void blk_limits_max_hw_sectors(struct queue_limits *limits, unsigned int max_hw_
 		       __func__, max_hw_sectors);
 	}
 
-	limits->max_sectors = limits->max_hw_sectors = max_hw_sectors;
+	if (limits->max_sectors == limits->max_hw_sectors ||
+	    max_hw_sectors < limits->max_sectors)
+		limits->max_sectors = limits->max_hw_sectors = max_hw_sectors;
+	else
+		limits->max_hw_sectors = max_hw_sectors;
 }
 EXPORT_SYMBOL(blk_limits_max_hw_sectors);
 
-- 
1.8.3.1


             reply	other threads:[~2015-04-10  7:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-10  7:08 michaelc [this message]
2015-04-10 18:04 ` [PATCH 1/1] block: don't overwrite max_sectors if user has set it Ewan Milne

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=1428649720-14316-1-git-send-email-michaelc@cs.wisc.edu \
    --to=michaelc@cs.wisc.edu \
    --cc=axboe@fb.com \
    --cc=linux-scsi@vger.kernel.org \
    /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