From patchwork Tue Nov 12 16:09:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 11239751 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8849A17E6 for ; Tue, 12 Nov 2019 16:10:07 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4608520679 for ; Tue, 12 Nov 2019 16:10:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TNWIYSCT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4608520679 Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573575006; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=F2/PMkQnl7U9KqbBJpkEMds1w0uO+RdLQcr128gknWU=; b=TNWIYSCTDQ9579P5Lkr9j5VxL5/YmS1ZmKFNo97pF7Rzd6iFqA6aVyilcoEY9tjKoEHDpz 4Zz7InHjh9+YZTJN/qqZwcaKOTPhhLBA138HtRolDLZKbRqzwPK6FCyjBugj4NueSpoRUw V2pPrtXJz60vyvipkb800aUKBMJSWj4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-40-1s37JDYoPUOHn3HbSbI4Xw-1; Tue, 12 Nov 2019 11:10:03 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B291018AB429; Tue, 12 Nov 2019 16:09:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 84F35610E5; Tue, 12 Nov 2019 16:09:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0BE3C4BB65; Tue, 12 Nov 2019 16:09:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xACG9soT009097 for ; Tue, 12 Nov 2019 11:09:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id B835128D39; Tue, 12 Nov 2019 16:09:54 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39F9C816E; Tue, 12 Nov 2019 16:09:52 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id xACG9pOd017623; Tue, 12 Nov 2019 11:09:51 -0500 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id xACG9pJr017619; Tue, 12 Nov 2019 11:09:51 -0500 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Tue, 12 Nov 2019 11:09:51 -0500 (EST) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Mike Snitzer Message-ID: User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: dm-devel@redhat.com Cc: Nikos Tsironis , Daniel Wagner , Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org, Ilias Tsitsimpis , dm-devel@redhat.com, linux-fsdevel@vger.kernel.org, tglx@linutronix.de, Scott Wood , linux-rt-users@vger.kernel.org Subject: [dm-devel] [PATCH RT 1/2 v2] dm-snapshot: fix crash with the realtime kernel X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: 1s37JDYoPUOHn3HbSbI4Xw-1 X-Mimecast-Spam-Score: 0 Snapshot doesn't work with realtime kernels since the commit f79ae415b64c. hlist_bl is implemented as a raw spinlock and the code takes two non-raw spinlocks while holding hlist_bl (non-raw spinlocks are blocking mutexes in the realtime kernel). We can't change hlist_bl to use non-raw spinlocks, this triggers warnings in dentry lookup code, because the dentry lookup code uses hlist_bl while holding a seqlock. This patch fixes the problem by using non-raw spinlock exception_table_lock instead of the hlist_bl lock. Signed-off-by: Mikulas Patocka Fixes: f79ae415b64c ("dm snapshot: Make exception tables scalable") Reviewed-by: Nikos Tsironis --- drivers/md/dm-snap.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6/drivers/md/dm-snap.c =================================================================== --- linux-2.6.orig/drivers/md/dm-snap.c 2019-11-12 16:44:36.000000000 +0100 +++ linux-2.6/drivers/md/dm-snap.c 2019-11-12 17:01:46.000000000 +0100 @@ -141,6 +141,10 @@ struct dm_snapshot { * for them to be committed. */ struct bio_list bios_queued_during_merge; + +#ifdef CONFIG_PREEMPT_RT_BASE + spinlock_t exception_table_lock; +#endif }; /* @@ -625,30 +629,46 @@ static uint32_t exception_hash(struct dm /* Lock to protect access to the completed and pending exception hash tables. */ struct dm_exception_table_lock { +#ifndef CONFIG_PREEMPT_RT_BASE struct hlist_bl_head *complete_slot; struct hlist_bl_head *pending_slot; +#else + spinlock_t *lock; +#endif }; static void dm_exception_table_lock_init(struct dm_snapshot *s, chunk_t chunk, struct dm_exception_table_lock *lock) { +#ifndef CONFIG_PREEMPT_RT_BASE struct dm_exception_table *complete = &s->complete; struct dm_exception_table *pending = &s->pending; lock->complete_slot = &complete->table[exception_hash(complete, chunk)]; lock->pending_slot = &pending->table[exception_hash(pending, chunk)]; +#else + lock->lock = &s->exception_table_lock; +#endif } static void dm_exception_table_lock(struct dm_exception_table_lock *lock) { +#ifndef CONFIG_PREEMPT_RT_BASE hlist_bl_lock(lock->complete_slot); hlist_bl_lock(lock->pending_slot); +#else + spin_lock(lock->lock); +#endif } static void dm_exception_table_unlock(struct dm_exception_table_lock *lock) { +#ifndef CONFIG_PREEMPT_RT_BASE hlist_bl_unlock(lock->pending_slot); hlist_bl_unlock(lock->complete_slot); +#else + spin_unlock(lock->lock); +#endif } static int dm_exception_table_init(struct dm_exception_table *et, @@ -1318,6 +1338,9 @@ static int snapshot_ctr(struct dm_target s->first_merging_chunk = 0; s->num_merging_chunks = 0; bio_list_init(&s->bios_queued_during_merge); +#ifdef CONFIG_PREEMPT_RT_BASE + spin_lock_init(&s->exception_table_lock); +#endif /* Allocate hash table for COW data */ if (init_hash_tables(s)) {