From patchwork Fri Apr 10 07:08:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 6192261 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DA7459F349 for ; Fri, 10 Apr 2015 07:09:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0484A203A0 for ; Fri, 10 Apr 2015 07:09:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EC1E12037A for ; Fri, 10 Apr 2015 07:08:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753824AbbDJHI6 (ORCPT ); Fri, 10 Apr 2015 03:08:58 -0400 Received: from sabe.cs.wisc.edu ([128.105.6.20]:45366 "EHLO sabe.cs.wisc.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752182AbbDJHI6 (ORCPT ); Fri, 10 Apr 2015 03:08:58 -0400 Received: from rh2.redhat.com (c-24-245-27-162.hsd1.mn.comcast.net [24.245.27.162]) (authenticated bits=0) by sabe.cs.wisc.edu (8.14.1/8.14.1) with ESMTP id t3A78nQT029840 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 10 Apr 2015 02:08:54 -0500 From: michaelc@cs.wisc.edu To: linux-scsi@vger.kernel.org, axboe@fb.com Cc: Mike Christie Subject: [PATCH 1/1] block: don't overwrite max_sectors if user has set it Date: Fri, 10 Apr 2015 02:08:40 -0500 Message-Id: <1428649720-14316-1-git-send-email-michaelc@cs.wisc.edu> X-Mailer: git-send-email 1.8.3.1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mike Christie 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 Reviewed-by: Ewan D. Milne --- 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//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);