Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp720783ybc; Tue, 12 Nov 2019 08:13:01 -0800 (PST) X-Google-Smtp-Source: APXvYqzFNtfb2D3lO7KmpTQYrMQtpz5XRw7fPKGkIbVG77nQQZ4OqLFcpM06OIpNPadGlK5UoqtS X-Received: by 2002:aa7:c444:: with SMTP id n4mr32148702edr.3.1573575181687; Tue, 12 Nov 2019 08:13:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573575181; cv=none; d=google.com; s=arc-20160816; b=IlK+WdZ0ESBqJ9QyZ4z5wQBNFW7G5aNhUaTUs1TbASVUC37ItjyIis+Lct4oM2HxIP VYWI8zNABe+pDFJAnZlW+0N8ZJucnt35GTEDfBiPXjAwwUnG+By3GA+HYhRi3jFsp1v6 SRehly9uij1NuA10Oudv38i8InBo/raz1gcp8uEGFYoF6laT4ksIl9ZouCsRONS/1T6A DOTThcJRgfwMaEepMyp77YWUW42oLnpArPuH3eAxNpt9+v/FxCQRByesDyetSWqD3LXY jLGAbJIArINHtNrl/YEo05t/CUlDbtFQgdcWllRZHMhtV70swa/CKoY5UnDpKlKlO0xD u7NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:subject:cc:to:from:date:dkim-signature; bh=c7nS+L24X7lJanaYypJtlLKF8SsjhTn6uG0Gv83hCho=; b=A3kTyJOBighFTg1Bd3CSuHRg+vbqxlEfH5Hhv4htXqMNDkCBPTDIaAKCn+TkbuSDho +cy5ykgY9kOJqBFvPmP1MvzIP877HjFAr+V8bvTz+esRcZ4Phmc841fR24P/FTg9iDpQ jbiKqCb0E6RIP19E/VjdD2jChHMqr8Gccp6a48lmT24vYsCPtxkSNCVSV+xJW6NS3fD5 QIkFcC6JTVg8ijSVSLQjoOPEIsaBTOSHKbHuC6c83Q6O9OKRhblTFZam96piqPCRIs71 GTl5cJEdd5+bqziaWWSMMJWhJ5Fdmro8vP2b5Trv9OJGt/COuvLWZhsGcndlSoz8P0un eW5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Lg5ayaLm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hh7si232080ejb.57.2019.11.12.08.12.37; Tue, 12 Nov 2019 08:13:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Lg5ayaLm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727357AbfKLQKA (ORCPT + 99 others); Tue, 12 Nov 2019 11:10:00 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:20338 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726953AbfKLQKA (ORCPT ); Tue, 12 Nov 2019 11:10:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573574999; h=from:from: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; bh=c7nS+L24X7lJanaYypJtlLKF8SsjhTn6uG0Gv83hCho=; b=Lg5ayaLmvi0WXqh0Q8yu8yuA6xIsjdEs/QYbBcT2Aw8/L0zzZTVlS3RYy/2F64JYP1O4wk h4fejeQ1rO8K4MsNdXf3qkdhWQpQhLU20hrR0qhyUteSp05oJwmUfoCT+SfkDTiw5T7JDN k3puLkBGVUYUKiGVlvl2gmDoNfdPsrk= 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-429-Iv-B_fuvOduL8bLkc3OrQg-1; Tue, 12 Nov 2019 11:09:56 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BA81FDC54; Tue, 12 Nov 2019 16:09:54 +0000 (UTC) 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 cc: Nikos Tsironis , Scott Wood , Ilias Tsitsimpis , dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Daniel Wagner , Sebastian Andrzej Siewior , linux-rt-users@vger.kernel.org, tglx@linutronix.de Subject: [PATCH RT 1/2 v2] dm-snapshot: fix crash with the realtime kernel 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-MC-Unique: Iv-B_fuvOduL8bLkc3OrQg-1 X-Mimecast-Spam-Score: 0 Content-Type: TEXT/PLAIN; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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= =20 in dentry lookup code, because the dentry lookup code uses hlist_bl while= =20 holding a seqlock. This patch fixes the problem by using non-raw spinlock=20 exception_table_lock instead of the hlist_bl lock. Signed-off-by: Mikulas Patocka Fixes: f79ae415b64c ("dm snapshot: Make exception tables scalable") --- drivers/md/dm-snap.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) Index: linux-2.6/drivers/md/dm-snap.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-2.6.orig/drivers/md/dm-snap.c=092019-11-12 16:44:36.000000000 +01= 00 +++ linux-2.6/drivers/md/dm-snap.c=092019-11-12 17:01:46.000000000 +0100 @@ -141,6 +141,10 @@ struct dm_snapshot { =09 * for them to be committed. =09 */ =09struct bio_list bios_queued_during_merge; + +#ifdef CONFIG_PREEMPT_RT_BASE +=09spinlock_t exception_table_lock; +#endif }; =20 /* @@ -625,30 +629,46 @@ static uint32_t exception_hash(struct dm =20 /* Lock to protect access to the completed and pending exception hash tabl= es. */ struct dm_exception_table_lock { +#ifndef CONFIG_PREEMPT_RT_BASE =09struct hlist_bl_head *complete_slot; =09struct hlist_bl_head *pending_slot; +#else +=09spinlock_t *lock; +#endif }; =20 static void dm_exception_table_lock_init(struct dm_snapshot *s, chunk_t ch= unk, =09=09=09=09=09 struct dm_exception_table_lock *lock) { +#ifndef CONFIG_PREEMPT_RT_BASE =09struct dm_exception_table *complete =3D &s->complete; =09struct dm_exception_table *pending =3D &s->pending; =20 =09lock->complete_slot =3D &complete->table[exception_hash(complete, chunk= )]; =09lock->pending_slot =3D &pending->table[exception_hash(pending, chunk)]; +#else +=09lock->lock =3D &s->exception_table_lock; +#endif } =20 static void dm_exception_table_lock(struct dm_exception_table_lock *lock) { +#ifndef CONFIG_PREEMPT_RT_BASE =09hlist_bl_lock(lock->complete_slot); =09hlist_bl_lock(lock->pending_slot); +#else +=09spin_lock(lock->lock); +#endif } =20 static void dm_exception_table_unlock(struct dm_exception_table_lock *lock= ) { +#ifndef CONFIG_PREEMPT_RT_BASE =09hlist_bl_unlock(lock->pending_slot); =09hlist_bl_unlock(lock->complete_slot); +#else +=09spin_unlock(lock->lock); +#endif } =20 static int dm_exception_table_init(struct dm_exception_table *et, @@ -1318,6 +1338,9 @@ static int snapshot_ctr(struct dm_target =09s->first_merging_chunk =3D 0; =09s->num_merging_chunks =3D 0; =09bio_list_init(&s->bios_queued_during_merge); +#ifdef CONFIG_PREEMPT_RT_BASE +=09spin_lock_init(&s->exception_table_lock); +#endif =20 =09/* Allocate hash table for COW data */ =09if (init_hash_tables(s)) {