From patchwork Fri Jul 22 14:49:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Florian-Ewald_M=C3=BCller?= X-Patchwork-Id: 9243731 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 16B50602F0 for ; Fri, 22 Jul 2016 14:50:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07E7827FAB for ; Fri, 22 Jul 2016 14:50:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0B3227FAD; Fri, 22 Jul 2016 14:49:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3963A27FAB for ; Fri, 22 Jul 2016 14:49:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751566AbcGVOt6 (ORCPT ); Fri, 22 Jul 2016 10:49:58 -0400 Received: from mail-oi0-f49.google.com ([209.85.218.49]:35379 "EHLO mail-oi0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751327AbcGVOt5 (ORCPT ); Fri, 22 Jul 2016 10:49:57 -0400 Received: by mail-oi0-f49.google.com with SMTP id l72so166024287oig.2 for ; Fri, 22 Jul 2016 07:49:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profitbricks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=8at0A6+ATX+dLa0BBicWYmzqlBBc5sTX4E5Wa/i8q/Q=; b=h+GLnU12dg/42Z/c91MnJdaPjPV1j3xRQWVGLbX9K+OpfCWH4Lk6/YupgT9g+BGr7K hJOjoeM0aasl+lBjb0MdVgf9N9HlmB1RjjZ/3TT5h6I/Lo0jpEOPwCnRjJnImvdzIQG2 UMJg37DZopmroWArTj0WwR93zKjD5y1RfvQaJTFHLiapDS4gI/6AmyBtapZAqi93PMS7 EaSLIf2tC+7Y0T3oPWeIIPrFkFhxZ1CWUBaZwuB50b0xNXY7DyzaAPBjj32eY5QK+WDy j9eALDdyjE3BzddTjUtXaV68MQqqX0HMUdOp3MM+J9WsjSl4drs6WWeF+Li9PEICcovF hRVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=8at0A6+ATX+dLa0BBicWYmzqlBBc5sTX4E5Wa/i8q/Q=; b=WghuqLVjU4ffYpmaNafQyKMWcZV/rXTqcXb9SayyFQKgXCYqP+ZN4sb6BSA5+VGGPu Id69O/vqc9Xhqwald/808XO2oVCq4+qKiMeTVJXpTymtfsUXExhQ+VfIryecMGdwhFVO yzuOmHqrDUDqZmZ7IZiG9Niqxz0xwL3MVtgFI+SnAs0j3QAOYYYSrl10zRAB8ap/JwId srMTkj6pnjeYqJHTpTREFiw5XJ6RQaXVSAsUouzdhbPKY2kdKC+GdBn3f8x4yZH08fCU mRphj/pU4e10Nt+XYmzN1SFXFo6mFNYUsKCChm3CBvfBmhSiH7ak7F2HPozAekuloXUD PPyw== X-Gm-Message-State: AEkoouucSwNYDQiPWlOiBC6f826UkqMbQQEFa93U8g8tH8xgExJLL+J3PO4wOqWmnhSsveBhUdIrb6D9zeQOBnp5 X-Received: by 10.157.61.137 with SMTP id l9mr2407738otc.31.1469198996838; Fri, 22 Jul 2016 07:49:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.18.130 with HTTP; Fri, 22 Jul 2016 07:49:37 -0700 (PDT) From: =?UTF-8?Q?Florian=2DEwald_M=C3=BCller?= Date: Fri, 22 Jul 2016 16:49:37 +0200 Message-ID: Subject: [PATCH linux-4.7-rc7] blk_stack_limits() setting discard_granularity To: linux-block@vger.kernel.org Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP blk_stack_limits() can set discard_granularity bigger than max_discard_sectors (in bytes). This makes blk_bio_discard_split() non-functional and can lead to data corruption. From: Florian-Ewald Mueller Subject: [PATCH] blk_stack_limits() blk_stack_limits() can set discard_granularity bigger than max_discard_sectors (in bytes). This makes blk_bio_discard_split() non-functional and can lead to data corruption. Signed-off-by: Florian-Ewald Mueller --- linux-4.7-rc7/block/blk-settings.c.orig 2016-07-21 19:39:44.831351396 +0200 +++ linux-4.7-rc7/block/blk-settings.c 2016-07-21 19:40:04.582968496 +0200 @@ -626,8 +626,10 @@ int blk_stack_limits(struct queue_limits b->max_hw_discard_sectors); t->discard_granularity = max(t->discard_granularity, b->discard_granularity); + if (t->discard_granularity > (t->max_discard_sectors << 9)) + t->discard_granularity = t->max_discard_sectors << 9; t->discard_alignment = lcm_not_zero(t->discard_alignment, alignment) % - t->discard_granularity; + (t->discard_granularity ? : 1); } return ret;