From patchwork Tue Apr 18 16:43:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9685833 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 07C51602C2 for ; Tue, 18 Apr 2017 16:44:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDF1928497 for ; Tue, 18 Apr 2017 16:44:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E28A22849D; Tue, 18 Apr 2017 16:44:31 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable 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 70AD128497 for ; Tue, 18 Apr 2017 16:44:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932492AbdDRQnu (ORCPT ); Tue, 18 Apr 2017 12:43:50 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33406 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753724AbdDRQnq (ORCPT ); Tue, 18 Apr 2017 12:43:46 -0400 Received: by mail-wm0-f65.google.com with SMTP id o81so456581wmb.0; Tue, 18 Apr 2017 09:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=1wAV2OVXmbi8y84fKc6Y74E1dD+4XtufKeBG970taoI=; b=IAghWxZ8ez2T6g6EtQnf5RvItibX/g6aGFOddPVE2f6xSklNgjoSuSschdbNZV0eq0 MDIyEJ2LtJQcdnshMq1KxKVZ2sFhQZRAS04yMMQ5xv+z/TGzq7XApFkPk5uht+BSEabP CTtjZnKYrFZCDuK27LSEHqsf7JOw/Z5vXDnDMF0pr3vNNecxOiHZkwTZt22SUyScXk1u VmgF5LjduK4ukFFHZP1JMCCB0h/0sRmj9oFEF1rkfrPp5oPpTkXtpFwHqU+CiowPfO/J +zCsfvgquDZ8UztFQH8q525qkAahndw461dR+flyxJecg1slXXJH46635Z3J8psBRUKT toOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1wAV2OVXmbi8y84fKc6Y74E1dD+4XtufKeBG970taoI=; b=HFXZtt80eAXMpastgq1Ymj9aS5B0cvG1tN3EJo+srz9wvDKnSCf1vd/lS8KbVnWy5T Ibh11iso2ZeAoIsIYflLde/wOEtmod+wud51vKiOMzPaMojCwdIbDQ24QFz35HVmYZYX eF0BsFVSKXrbjj9Ndz5nGQ4aGL4F1TGPbs6z2CVx4yFo+0ttZH7Za8d0svEpD5rQ5WoI QulSmyBHtAUT22ZwjB0EONPm/vG2/BmD2NknTuhlLYPb0dzIl0EkJ0OhK45ACA78ciZ/ 3aF3cNARRCaUcaRyek8eYaavCqmYubdWqzLB3/vigyfG4hdIIerbnQPkW6dIlLQ4QVFc PgdQ== X-Gm-Message-State: AN3rC/4fNJv/BKuF7q5ygVTwaQqGlalsSq3vF4bRFDz3EjNzQu6UiN7I vyNrq5oy2jrkpg== X-Received: by 10.28.65.65 with SMTP id o62mr13323778wma.14.1492533824609; Tue, 18 Apr 2017 09:43:44 -0700 (PDT) Received: from orange.redhat.com (ip-213-220-221-251.net.upcbroadband.cz. [213.220.221.251]) by smtp.gmail.com with ESMTPSA id b10sm15595031wme.22.2017.04.18.09.43.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Apr 2017 09:43:43 -0700 (PDT) From: Ilya Dryomov To: "Martin K. Petersen" Cc: Dan Williams , Christoph Hellwig , Mike Snitzer , Jens Axboe , linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, dm-devel@redhat.com, ceph-devel@vger.kernel.org Subject: [PATCH] block: get rid of blk_integrity_revalidate() Date: Tue, 18 Apr 2017 18:43:20 +0200 Message-Id: <1492533800-30627-1-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 2.4.3 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 Commit 25520d55cdb6 ("block: Inline blk_integrity in struct gendisk") introduced blk_integrity_revalidate(), which seems to assume ownership of the stable pages flag and unilaterally clears it if no blk_integrity profile is registered: if (bi->profile) disk->queue->backing_dev_info->capabilities |= BDI_CAP_STABLE_WRITES; else disk->queue->backing_dev_info->capabilities &= ~BDI_CAP_STABLE_WRITES; It's called from revalidate_disk() and rescan_partitions(), making it impossible to enable stable pages for drivers that support partitions and don't use blk_integrity: while the call in revalidate_disk() can be trivially worked around (see zram, which doesn't support partitions and hence gets away with zram_revalidate_disk()), rescan_partitions() can be triggered from userspace at any time. This breaks rbd, where the ceph messenger is responsible for generating/verifying CRCs. Since blk_integrity_{un,}register() "must" be used for (un)registering the integrity profile with the block layer, move BDI_CAP_STABLE_WRITES setting there. This way drivers that call blk_integrity_register() and use integrity infrastructure won't interfere with drivers that don't but still want stable pages. Fixes: 25520d55cdb6 ("block: Inline blk_integrity in struct gendisk") Cc: "Martin K. Petersen" Cc: Dan Williams Cc: Christoph Hellwig Cc: Mike Snitzer Cc: stable@vger.kernel.org # 4.4+, needs backporting Signed-off-by: Ilya Dryomov Tested-by: Dan Williams --- I don't have any integrity-capable disks or nvme separate-metadata cards, so I couldn't test this as well as I wanted to. 25520d55cdb6 went in with some nvme work, but Martin recalls that it may have had something to do with integrity-capable dm arrays losing the integrity capability at runtime. Previous discussion at http://www.spinics.net/lists/ceph-devel/msg35413.html --- block/blk-integrity.c | 19 ++----------------- block/partition-generic.c | 1 - fs/block_dev.c | 1 - include/linux/genhd.h | 2 -- 4 files changed, 2 insertions(+), 21 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 9f0ff5ba4f84..35c5af1ea068 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -417,7 +417,7 @@ void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template bi->tuple_size = template->tuple_size; bi->tag_size = template->tag_size; - blk_integrity_revalidate(disk); + disk->queue->backing_dev_info->capabilities |= BDI_CAP_STABLE_WRITES; } EXPORT_SYMBOL(blk_integrity_register); @@ -430,26 +430,11 @@ EXPORT_SYMBOL(blk_integrity_register); */ void blk_integrity_unregister(struct gendisk *disk) { - blk_integrity_revalidate(disk); + disk->queue->backing_dev_info->capabilities &= ~BDI_CAP_STABLE_WRITES; memset(&disk->queue->integrity, 0, sizeof(struct blk_integrity)); } EXPORT_SYMBOL(blk_integrity_unregister); -void blk_integrity_revalidate(struct gendisk *disk) -{ - struct blk_integrity *bi = &disk->queue->integrity; - - if (!(disk->flags & GENHD_FL_UP)) - return; - - if (bi->profile) - disk->queue->backing_dev_info->capabilities |= - BDI_CAP_STABLE_WRITES; - else - disk->queue->backing_dev_info->capabilities &= - ~BDI_CAP_STABLE_WRITES; -} - void blk_integrity_add(struct gendisk *disk) { if (kobject_init_and_add(&disk->integrity_kobj, &integrity_ktype, diff --git a/block/partition-generic.c b/block/partition-generic.c index 7afb9907821f..0171a2faad68 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -497,7 +497,6 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev) if (disk->fops->revalidate_disk) disk->fops->revalidate_disk(disk); - blk_integrity_revalidate(disk); check_disk_size_change(disk, bdev); bdev->bd_invalidated = 0; if (!get_capacity(disk) || !(state = check_partition(disk, bdev))) diff --git a/fs/block_dev.c b/fs/block_dev.c index 2eca00ec4370..56039dfbc674 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1451,7 +1451,6 @@ int revalidate_disk(struct gendisk *disk) if (disk->fops->revalidate_disk) ret = disk->fops->revalidate_disk(disk); - blk_integrity_revalidate(disk); bdev = bdget_disk(disk, 0); if (!bdev) return ret; diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 76f39754e7b0..76d6a1cd4153 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -722,11 +722,9 @@ static inline void part_nr_sects_write(struct hd_struct *part, sector_t size) #if defined(CONFIG_BLK_DEV_INTEGRITY) extern void blk_integrity_add(struct gendisk *); extern void blk_integrity_del(struct gendisk *); -extern void blk_integrity_revalidate(struct gendisk *); #else /* CONFIG_BLK_DEV_INTEGRITY */ static inline void blk_integrity_add(struct gendisk *disk) { } static inline void blk_integrity_del(struct gendisk *disk) { } -static inline void blk_integrity_revalidate(struct gendisk *disk) { } #endif /* CONFIG_BLK_DEV_INTEGRITY */ #else /* CONFIG_BLOCK */