From patchwork Tue Nov 20 10:20:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huaisheng Ye X-Patchwork-Id: 10692179 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5891613BB for ; Wed, 21 Nov 2018 09:28:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 454DE2B810 for ; Wed, 21 Nov 2018 09:28:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38D042B814; Wed, 21 Nov 2018 09:28:04 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C73D42B80C for ; Wed, 21 Nov 2018 09:28:03 +0000 (UTC) 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 mx1.redhat.com (Postfix) with ESMTPS id C887630A02D7; Wed, 21 Nov 2018 09:28:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 958D2277C0; Wed, 21 Nov 2018 09:28:02 +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 4E123181B9E9; Wed, 21 Nov 2018 09:28:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAKALD8E016896 for ; Tue, 20 Nov 2018 05:21:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 57BA31054FD3; Tue, 20 Nov 2018 10:21:13 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DF911042557; Tue, 20 Nov 2018 10:21:09 +0000 (UTC) Received: from sender-pp-092.zoho.com (sender-pp-092.zoho.com [135.84.80.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 462FF8764F; Tue, 20 Nov 2018 10:21:07 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1542709266; cv=none; d=zoho.com; s=zohoarc; b=a6eNsrEllAIGuZL1CE5Pqd2LFSC4nWJVS5Of5X7S2GkKz+Uvrauq4hk/574CKOLRBW8wv8RNNeAIxp3hMkjOPNn+vNjhREYD7C9ZI/EGjeAp7tY6R6hoBRkNruRJjLe/uozb1a492L73u3CLMsSbjiAslWCw+Vst3KFUnll1yJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1542709266; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=Vg83GLY1TOcUwu8LjDRYZyK2VKe0/QCPhNa/U9/9R6M=; b=JIPH+MyavnKmBwIA/HazuIEwozZ6Z6OkgOgfbdIeQ7pq+tZ2TCFMRTNpmoVB4GFzB5Aq6LK7mM/n+WL/UDPNBXe6e3qwhOiQwhZvlmwINNI6CghyBRpin6o0/ANkYTLoN3G0PKDTv1gnJRZWWbp5xc+cFHvhVzJLRIb9mAZmpaU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=yehs2007@zoho.com; dmarc=pass header.from= header.from= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=from:to:cc:subject:date:message-id:in-reply-to:references; b=mOVLI4C+sn4d7a8duqge+unEuTghEoHiR3EyaJ7WninqreTigjuxgZCZ0t5RQn8NBhq+mK5l/+Eq 0OWkPNNtqNVM06JtSrHYRB/scDU+ljtWtCSTT6syuQmvYpvic2qi DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1542709266; s=default; d=zoho.com; i=yehs2007@zoho.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=3603; bh=Vg83GLY1TOcUwu8LjDRYZyK2VKe0/QCPhNa/U9/9R6M=; b=hlh8V0bBj+T3E7thp9EChvsdGBCJ/LqkUeLOAqXHfQ1akM5t6N9u6qFDOv4licFm D8zyauf2xbFUZQwpC/3wY+6Odvy37M3TTx21OOtKKGtme8lHA9OE5a5Ii2NFS2FwJ7V ktAdaKYR5S6A5ijodWjwxs/bOXPA3jwq539om9+8= Received: from YEHS1XR956R00D1.lenovo.com (58.243.153.247 [58.243.153.247]) by mx.zohomail.com with SMTPS id 1542709265287568.4244900576812; Tue, 20 Nov 2018 02:21:05 -0800 (PST) From: Huaisheng Ye To: linux-nvdimm@lists.01.org, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, dan.j.williams@intel.com, willy@infradead.org, zwisler@kernel.org, jack@suse.cz, dave.jiang@intel.com, vishal.l.verma@intel.com Date: Tue, 20 Nov 2018 18:20:35 +0800 Message-Id: <20181120102037.4536-2-yehs2007@zoho.com> In-Reply-To: <20181120102037.4536-1-yehs2007@zoho.com> References: <20181120102037.4536-1-yehs2007@zoho.com> X-ZohoMailClient: External X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 20 Nov 2018 10:21:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 20 Nov 2018 10:21:07 +0000 (UTC) for IP:'135.84.80.237' DOMAIN:'sender-pp-092.zoho.com' HELO:'sender-pp-092.zoho.com' FROM:'yehs2007@zoho.com' RCPT:'' X-RedHat-Spam-Score: 0.14 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 135.84.80.237 sender-pp-092.zoho.com 135.84.80.237 sender-pp-092.zoho.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Wed, 21 Nov 2018 04:27:48 -0500 Cc: linux-fsdevel@vger.kernel.org, chengnt@lenovo.com, linux-kernel@vger.kernel.org, Huaisheng Ye Subject: [dm-devel] [RFC PATCH 1/3] dm: enable dax_operations for dm-snapshot 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: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 21 Nov 2018 09:28:03 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP From: Huaisheng Ye Reconstruct origin_dax_direct_access and expand functions origin_dax_copy_to/from_iter for DAX operations of dm-snapshot. Here is the call trace of origin_dax_copy_to_iter, origin_dax_copy_to_iter will callin dm-linear (-real) for further dax_operation. [518597.924019] Call Trace: [518597.927320] dump_stack+0x65/0x7e [518597.931592] origin_dax_copy_to_iter+0x51/0x78 [dm_snapshot] [518597.938494] dm_dax_copy_to_iter+0x86/0xc5 [dm_mod] [518597.944519] dax_copy_to_iter+0x27/0x29 [518597.949371] dax_iomap_actor+0x264/0x326 [518597.954308] ? trace_event_raw_event_dax_pmd_load_hole_class+0xd0/0xd0 [518597.962159] iomap_apply+0xc7/0x128 [518597.966609] ? trace_event_raw_event_dax_pmd_load_hole_class+0xd0/0xd0 [518597.974447] dax_iomap_rw+0x66/0xa8 [518597.978893] ? trace_event_raw_event_dax_pmd_load_hole_class+0xd0/0xd0 [518597.986741] ext2_file_read_iter+0x4f/0x83 [ext2] [518597.992552] __vfs_read+0x130/0x168 [518597.997001] vfs_read+0x92/0x146 [518598.001155] ksys_read+0x4f/0xa5 [518598.005308] __x64_sys_read+0x16/0x18 [518598.009942] do_syscall_64+0x88/0x15f [518598.014575] entry_SYSCALL_64_after_hwframe+0x44/0xa9 Signed-off-by: Huaisheng Ye --- drivers/md/dm-snap.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index ae4b33d..75738b3 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "dm.h" @@ -2319,8 +2320,45 @@ static int origin_map(struct dm_target *ti, struct bio *bio) static long origin_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn) { - DMWARN("device does not support dax."); - return -EIO; + long ret = 0; + struct dm_origin *o = ti->private; + struct block_device *bdev = o->dev->bdev; + struct dax_device *dax_dev = o->dev->dax_dev; + sector_t sector = pgoff * PAGE_SECTORS; + + ret = bdev_dax_pgoff(bdev, sector, nr_pages * PAGE_SIZE, &pgoff); + if (ret) + return ret; + + return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); +} + +static size_t origin_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + struct dm_origin *o = ti->private; + struct block_device *bdev = o->dev->bdev; + struct dax_device *dax_dev = o->dev->dax_dev; + sector_t sector = pgoff * PAGE_SECTORS; + + if (bdev_dax_pgoff(bdev, sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + return 0; + + return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); +} + +static size_t origin_dax_copy_to_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + struct dm_origin *o = ti->private; + struct block_device *bdev = o->dev->bdev; + struct dax_device *dax_dev = o->dev->dax_dev; + sector_t sector = pgoff * PAGE_SECTORS; + + if (bdev_dax_pgoff(bdev, sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + return 0; + + return dax_copy_to_iter(dax_dev, pgoff, addr, bytes, i); } /* @@ -2383,6 +2421,8 @@ static int origin_iterate_devices(struct dm_target *ti, .status = origin_status, .iterate_devices = origin_iterate_devices, .direct_access = origin_dax_direct_access, + .dax_copy_to_iter = origin_dax_copy_to_iter, + .dax_copy_from_iter = origin_dax_copy_from_iter, }; static struct target_type snapshot_target = { From patchwork Tue Nov 20 10:20:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huaisheng Ye X-Patchwork-Id: 10692175 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B9FAF13AD for ; Wed, 21 Nov 2018 09:27:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A73292B80C for ; Wed, 21 Nov 2018 09:27:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B5A62B816; Wed, 21 Nov 2018 09:27:53 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3CFAC2B814 for ; Wed, 21 Nov 2018 09:27:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 699DFC028345; Wed, 21 Nov 2018 09:27:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 405B25D760; Wed, 21 Nov 2018 09:27:50 +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 DBE51181B9E3; Wed, 21 Nov 2018 09:27:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAKALSY7017232 for ; Tue, 20 Nov 2018 05:21:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 943971834F; Tue, 20 Nov 2018 10:21:28 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A03818E5E; Tue, 20 Nov 2018 10:21:26 +0000 (UTC) Received: from sender-pp-092.zoho.com (sender-pp-092.zoho.com [135.84.80.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C25703DDB5; Tue, 20 Nov 2018 10:21:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1542709282; cv=none; d=zoho.com; s=zohoarc; b=hTxHz5DGo19Ny9KMCReq6pElGw2VHGwsKbTeYoZXI9kGN6S8H8sDecAp8pVyLs6ninaT9miuDLW/P1sjNUFXmNVVOzAcz/Dzq2q0TUNJLS2e/kx7FsHOpcJh2qEQK4qQO0oEdbGHpIrS0J5NNoiA0nu/8kLLMNftUEOhfmOZvAA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1542709282; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=jTSA+Zs1+7240+81mturwydytJwomKEmU0d3STdG9hM=; b=lhNnEjVi2k4UpZtnIZz/EDS7ttApQ/sADEH91ZlSLW5cS+Oc3tmyuCE0qHlpp6T6cvCOj1olkjEkCxXSXhAAt0NW361kESDQVlAO6HHjFuVGiireWzgmg3KxbKzw6DnmpZpoDRs5U5EXBVM6ybDY4ps4hWbk0ZWEFqzMpTL8PU0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=yehs2007@zoho.com; dmarc=pass header.from= header.from= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=from:to:cc:subject:date:message-id:in-reply-to:references; b=v+ol4wC+zrNtnk+7oNXY8mD2caQFtrhFLHi8DranfE7G2ydwK/v8awFDm4DJIUXtg1a3jBV2ZPoy 0N8oJCLZ77iYZGI1IBj/4EJlTTg9IyBqTVRHRhfMI5kMRzHSp0Qy DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1542709282; s=default; d=zoho.com; i=yehs2007@zoho.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=3228; bh=jTSA+Zs1+7240+81mturwydytJwomKEmU0d3STdG9hM=; b=mKwGN9wEH4U4+Hj3tm2/faI6lZ14eTWQJdCZobeae/vUakbmNjb+CTrCsak7245Z Apa9FCzTzlTLQhL9M0ePhrGIsJuVqvzbRuAny07KUklZsUV7A+9bEAL1HfOYMPiLPi4 Xmq9ZdeOThiJhtQ1bCi3r75IYym1qYMdZlo78+g4= Received: from YEHS1XR956R00D1.lenovo.com (58.243.153.247 [58.243.153.247]) by mx.zohomail.com with SMTPS id 1542709279011240.5816416360435; Tue, 20 Nov 2018 02:21:19 -0800 (PST) From: Huaisheng Ye To: linux-nvdimm@lists.01.org, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, dan.j.williams@intel.com, willy@infradead.org, zwisler@kernel.org, jack@suse.cz, dave.jiang@intel.com, vishal.l.verma@intel.com Date: Tue, 20 Nov 2018 18:20:36 +0800 Message-Id: <20181120102037.4536-3-yehs2007@zoho.com> In-Reply-To: <20181120102037.4536-1-yehs2007@zoho.com> References: <20181120102037.4536-1-yehs2007@zoho.com> X-ZohoMailClient: External X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 20 Nov 2018 10:21:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 20 Nov 2018 10:21:25 +0000 (UTC) for IP:'135.84.80.237' DOMAIN:'sender-pp-092.zoho.com' HELO:'sender-pp-092.zoho.com' FROM:'yehs2007@zoho.com' RCPT:'' X-RedHat-Spam-Score: 0.14 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 135.84.80.237 sender-pp-092.zoho.com 135.84.80.237 sender-pp-092.zoho.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Wed, 21 Nov 2018 04:27:48 -0500 Cc: linux-fsdevel@vger.kernel.org, chengnt@lenovo.com, linux-kernel@vger.kernel.org, Huaisheng Ye Subject: [dm-devel] [RFC PATCH 2/3] dm: expand hc_map in mapped_device for lack of map 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: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 21 Nov 2018 09:27:51 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP From: Huaisheng Ye Sometimes dm_swap_table couldn't be used in time. For example, during the origin construction of dm-snapshot, the sys_ioctl table_load will try to detect the lower device origin-real whether support direct access or not. But origin-real md's struct dm-table pointer has not yet been assigned real address in time by dev_suspend. So I expand hc_map for get the address from struct hash_cell directly in this case. Here is the call trace, dm_dax_direct_access will call dm_dax_get_live_target for get the struct dm_table pointer. [ 213.975827] Call Trace: [ 213.975832] dump_stack+0x5a/0x73 [ 213.975840] dm_dax_direct_access+0x12b/0x1b0 [dm_mod] [ 213.975845] dax_direct_access+0x2d/0x60 [ 213.975848] __bdev_dax_supported+0x162/0x2a0 [ 213.975851] ? dump_stack+0x5a/0x73 [ 213.975859] device_supports_dax+0x15/0x20 [dm_mod] [ 213.975867] dm_table_supports_dax.isra.13+0x7d/0xa0 [dm_mod] [ 213.975875] dm_table_complete+0x3fb/0x750 [dm_mod] [ 213.975883] table_load+0x19a/0x390 [dm_mod] [ 213.975891] ? retrieve_status+0x1c0/0x1c0 [dm_mod] [ 213.975898] ctl_ioctl+0x1d8/0x450 [dm_mod] [ 213.975909] dm_ctl_ioctl+0xa/0x10 [dm_mod] [ 213.975913] do_vfs_ioctl+0xa9/0x620 [ 213.975918] ? syscall_trace_enter+0x1c9/0x2b0 [ 213.975923] ksys_ioctl+0x60/0x90 [ 213.975927] __x64_sys_ioctl+0x16/0x20 [ 213.975931] do_syscall_64+0x5b/0x180 [ 213.975936] entry_SYSCALL_64_after_hwframe+0x44/0xa9 Signed-off-by: Huaisheng Ye --- drivers/md/dm-core.h | 1 + drivers/md/dm-ioctl.c | 1 + drivers/md/dm.c | 15 +++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h index 224d445..5577d90 100644 --- a/drivers/md/dm-core.h +++ b/drivers/md/dm-core.h @@ -40,6 +40,7 @@ struct mapped_device { * dereference. */ void __rcu *map; + struct dm_table *hc_map; unsigned long flags; diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index f666778..a27016e 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1365,6 +1365,7 @@ static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_si if (hc->new_map) old_map = hc->new_map; hc->new_map = t; + hc->md->hc_map = hc->new_map; up_write(&_hash_lock); param->flags |= DM_INACTIVE_PRESENT_FLAG; diff --git a/drivers/md/dm.c b/drivers/md/dm.c index c510179..19b48bb 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1080,6 +1080,21 @@ static struct dm_target *dm_dax_get_live_target(struct mapped_device *md, struct dm_target *ti; map = dm_get_live_table(md, srcu_idx); + if (!map) { + /* Sometimes dm_swap_table couldn't be used in time. + * + * For example, during the origin construction of + * dm-snapshot, the sys_ioctl table_load will try to + * detect the lower device origin-real whether support + * direct access or not. But origin-real device md's struct + * dm-table pointer has not yet been assigned real address. + * So hc_map has been used for get the address from + * struct hash_cell directly. + */ + DMINFO("failed to get map, use hc_map insteadly"); + map = md->hc_map; + } + if (!map) return NULL; From patchwork Tue Nov 20 10:20:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huaisheng Ye X-Patchwork-Id: 10692181 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BAFC713AD for ; Wed, 21 Nov 2018 09:28:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A68272B80C for ; Wed, 21 Nov 2018 09:28:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A62B2B814; Wed, 21 Nov 2018 09:28:04 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 430842B80C for ; Wed, 21 Nov 2018 09:28:04 +0000 (UTC) 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 mx1.redhat.com (Postfix) with ESMTPS id 302D1307D84C; Wed, 21 Nov 2018 09:28:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0152F705B2; Wed, 21 Nov 2018 09:28:03 +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 AC06F181B9EB; Wed, 21 Nov 2018 09:28:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAKALUZN017237 for ; Tue, 20 Nov 2018 05:21:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9CFCD179D1; Tue, 20 Nov 2018 10:21:30 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A5825D979; Tue, 20 Nov 2018 10:21:30 +0000 (UTC) Received: from sender-pp-092.zoho.com (sender-pp-092.zoho.com [135.84.80.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 650D3312E9D2; Tue, 20 Nov 2018 10:21:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1542709287; cv=none; d=zoho.com; s=zohoarc; b=Q7EuFKCNpEWAFLIJlK1cYneAB4xYIifVbUUi9l8/RjQrpQviuBKzOCtoUjJvoGgPosswQmzvmj6t1gHWZfS2PKRC6N/2vILDPki/ROPHjmeWekZ2o+QjHKIqbr/KZe93a/hyolZJzwLlPkznZlYUrqvMPrNx9nqG/1/MBDrtCA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1542709287; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=GHh1ilgk8ZdCIo8lwzMZINvkNuuU7rjdcC8nSOe4YS4=; b=JshvvVSeKvGq0W/MWkOgV+lolwe2BMjrC3sLidUqWK3Bo+sB3qG2Hr4gzNRyYzKpFF5WjO0TEwP/vccfPxkQLR2IKL92HlBxBZmdddppV3IKFGQUrHlZJ2sHjCG+mrD1yQ/hA1H3NpENkeNEK7/HlgkT4Dq4SB03uEvo3sXhivM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=yehs2007@zoho.com; dmarc=pass header.from= header.from= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=from:to:cc:subject:date:message-id:in-reply-to:references; b=PRJ0BZSCl2Y8jcBUX2b/SG3G/ZvQrI6I+sn0PcFlqFv5j5PGuH1N3v/aFmGteNYF4RGgd8QIWuL0 Ex77TMkB9phPhE8WrsmyoLqSgYDfTvCCTmoolMV3FGPeQzt/XziZ DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1542709287; s=default; d=zoho.com; i=yehs2007@zoho.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=1150; bh=GHh1ilgk8ZdCIo8lwzMZINvkNuuU7rjdcC8nSOe4YS4=; b=KGazHKFwhgtqQqo0CnoGftEYRLjZZyaVGcZQhFwzeyu85rMJ+IwjMcC2L95uT1ly xNeB2Nhm6zwXFaiG7hvm0p0wD0jLj902qYvePAY/pv/iGMnkUaWOq42CXLXRGX4P7kG MZU8E34kVC0JVY/nakZLsMV/+POExLGudTI1O2hc= Received: from YEHS1XR956R00D1.lenovo.com (58.243.153.247 [58.243.153.247]) by mx.zohomail.com with SMTPS id 1542709286690283.4299240192355; Tue, 20 Nov 2018 02:21:26 -0800 (PST) From: Huaisheng Ye To: linux-nvdimm@lists.01.org, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, dan.j.williams@intel.com, willy@infradead.org, zwisler@kernel.org, jack@suse.cz, dave.jiang@intel.com, vishal.l.verma@intel.com Date: Tue, 20 Nov 2018 18:20:37 +0800 Message-Id: <20181120102037.4536-4-yehs2007@zoho.com> In-Reply-To: <20181120102037.4536-1-yehs2007@zoho.com> References: <20181120102037.4536-1-yehs2007@zoho.com> X-ZohoMailClient: External X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 20 Nov 2018 10:21:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 20 Nov 2018 10:21:29 +0000 (UTC) for IP:'135.84.80.237' DOMAIN:'sender-pp-092.zoho.com' HELO:'sender-pp-092.zoho.com' FROM:'yehs2007@zoho.com' RCPT:'' X-RedHat-Spam-Score: 0.14 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 135.84.80.237 sender-pp-092.zoho.com 135.84.80.237 sender-pp-092.zoho.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Wed, 21 Nov 2018 04:27:48 -0500 Cc: linux-fsdevel@vger.kernel.org, chengnt@lenovo.com, linux-kernel@vger.kernel.org, Huaisheng Ye Subject: [dm-devel] [RFC PATCH 3/3] dm: expand valid types for dm-ioctl 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: , MIME-Version: 1.0 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 21 Nov 2018 09:28:03 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP From: Huaisheng Ye If use DAX way to mount the origin device of dm_snapshot, when merging back snapshot to origin, system call table_load during the construction of snapshot-merge will try to detect new dm_table's type equals to the existed md's type or not. The existed type equals to DM_TYPE_DAX_BIO_BASED, but the new created type belongs to DM_TYPE_BIO_BASED. So, we need to expand valid_type in function is_valid_type. Signed-off-by: Huaisheng Ye --- drivers/md/dm-ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index a27016e..158d657 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1295,7 +1295,8 @@ static int populate_table(struct dm_table *table, static bool is_valid_type(enum dm_queue_mode cur, enum dm_queue_mode new) { if (cur == new || - (cur == DM_TYPE_BIO_BASED && new == DM_TYPE_DAX_BIO_BASED)) + (cur == DM_TYPE_BIO_BASED && new == DM_TYPE_DAX_BIO_BASED) || + (cur == DM_TYPE_DAX_BIO_BASED && new == DM_TYPE_BIO_BASED)) return true; return false;