From patchwork Wed May 30 16:11:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 10439345 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.web.codeaurora.org (Postfix) with ESMTP id 055A0602CC for ; Wed, 30 May 2018 16:13:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D590B290E5 for ; Wed, 30 May 2018 16:13:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D356529142; Wed, 30 May 2018 16:13: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.9 required=2.0 tests=BAYES_00, 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 88130295A5 for ; Wed, 30 May 2018 16:11:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 55812C0B2A4F; Wed, 30 May 2018 16:11:20 +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 8D0931001917; Wed, 30 May 2018 16:11:19 +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 516654CA81; Wed, 30 May 2018 16:11:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4UGBGX4029947 for ; Wed, 30 May 2018 12:11:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id D156A2026988; Wed, 30 May 2018 16:11:16 +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 C275C2026DEF; Wed, 30 May 2018 16:11:16 +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 w4UGBGJR015164; Wed, 30 May 2018 12:11:16 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w4UGBGNZ015161; Wed, 30 May 2018 12:11:16 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Wed, 30 May 2018 12:11:16 -0400 (EDT) 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.78 on 10.11.54.4 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com Subject: [dm-devel] [PATCH] dm-writecache changes 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 30 May 2018 16:11:20 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP This patch removes the per-architecture abstraction. Only pmem_assign is left, because it is more convenient to use than memcpy_flushcache (and also, on architectures that don't support persistent memory, we want to redefine pmem_assign so that it doesn't flush the cache). It also fixes a test for failure of dm_io_client_create and dm_kcopyd_client_create. Signed-off-by: Mikulas Patocka --- drivers/md/dm-writecache.c | 72 ++++++--------------------------------------- 1 file changed, 11 insertions(+), 61 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6/drivers/md/dm-writecache.c =================================================================== --- linux-2.6.orig/drivers/md/dm-writecache.c 2018-05-30 17:38:22.000000000 +0200 +++ linux-2.6/drivers/md/dm-writecache.c 2018-05-30 18:02:13.000000000 +0200 @@ -34,60 +34,12 @@ #define BITMAP_GRANULARITY PAGE_SIZE #endif -/* - * API for optimized flushing of persistent memory: - * On X86, non-temporal stores are more efficient than cache flushing. - * On ARM64, cache flushing is more efficient. - * - * This API is a candidate for being elevated out of DM but for now - * it serves to cleanly allow optimized flushing without excessive - * branching throughout this target's code. - */ -#if defined(CONFIG_X86_64) - -#define __pmem_assign(dest, src, uniq) \ +#define pmem_assign(dest, src) \ do { \ typeof(dest) uniq = (src); \ memcpy_flushcache(&(dest), &uniq, sizeof(dest)); \ } while (0) -#define pmem_assign(dest, src) \ - __pmem_assign(dest, src, __UNIQUE_ID(pmem_assign)) - -static void pmem_memcpy(void *dest, void *src, size_t len) -{ - memcpy_flushcache(dest, src, len); -} - -static void pmem_flush(void *dest, size_t len) -{ -} - -static void pmem_commit(void) -{ - wmb(); -} - -#else - -#define pmem_assign(dest, src) WRITE_ONCE(dest, src) - -static void pmem_memcpy(void *dest, void *src, size_t len) -{ - memcpy(dest, src, len); -} - -static void pmem_flush(void *dest, size_t len) -{ - arch_wb_cache_pmem(dest, len); -} - -static void pmem_commit(void) -{ -} - -#endif - #if defined(__HAVE_ARCH_MEMCPY_MCSAFE) && defined(CONFIG_ARCH_HAS_PMEM_API) #define DM_WRITECACHE_HANDLE_HARDWARE_ERRORS #endif @@ -450,17 +402,13 @@ do { \ static void writecache_flush_all_metadata(struct dm_writecache *wc) { - if (WC_MODE_PMEM(wc)) - pmem_flush(sb(wc), offsetof(struct wc_memory_superblock, entries[wc->n_blocks])); - else + if (!WC_MODE_PMEM(wc)) memset(wc->dirty_bitmap, -1, wc->dirty_bitmap_size); } static void writecache_flush_region(struct dm_writecache *wc, void *ptr, size_t size) { - if (WC_MODE_PMEM(wc)) - pmem_flush(ptr, size); - else + if (!WC_MODE_PMEM(wc)) __set_bit(((char *)ptr - (char *)wc->memory_map) / BITMAP_GRANULARITY, wc->dirty_bitmap); } @@ -537,7 +485,7 @@ static void ssd_commit_flushed(struct dm static void writecache_commit_flushed(struct dm_writecache *wc) { if (WC_MODE_PMEM(wc)) - pmem_commit(); + wmb(); else ssd_commit_flushed(wc); } @@ -1090,7 +1038,7 @@ static void bio_copy_block(struct dm_wri } } else { flush_dcache_page(bio_page(bio)); - pmem_memcpy(data, buf, size); + memcpy_flushcache(data, buf, size); } bvec_kunmap_irq(buf, &flags); @@ -1872,9 +1820,10 @@ static int writecache_ctr(struct dm_targ } wc->dm_io = dm_io_client_create(); - if (!wc->dm_io) { - r = -ENOMEM; + if (IS_ERR(wc->dm_io)) { + r = PTR_ERR(wc->dm_io); ti->error = "Unable to allocate dm-io client"; + wc->dm_io = NULL; goto bad; } @@ -2096,9 +2045,10 @@ invalid_optional: } wc->dm_kcopyd = dm_kcopyd_client_create(&dm_kcopyd_throttle); - if (!wc->dm_kcopyd) { - r = -ENOMEM; + if (IS_ERR(wc->dm_kcopyd)) { + r = PTR_ERR(wc->dm_kcopyd); ti->error = "Unable to allocate dm-kcopyd client"; + wc->dm_kcopyd = NULL; goto bad; }