From patchwork Tue Feb 18 21:48:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Goyal X-Patchwork-Id: 11389791 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 EB87B109A for ; Tue, 18 Feb 2020 21:49:24 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AA04C206E2 for ; Tue, 18 Feb 2020 21:49:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TD+0p6WA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA04C206E2 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=1582062563; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6F49/r16l60ONoG9EeUcyzBibCQDgv2veuS8y8NCq3M=; b=TD+0p6WA5kJDd+EA94qBkW3xVCAmHCs8gL3jPo/d/a8AYSU6Vkn/PMiSPhQ8jXx7GpJ6g6 ZIULU85Grl3P55nb8vjWJgfJbESLWJOZ1w4lZx7QoCke4G6r3gyBHwWCFCKtxXstx5ItE2 AQ5RuqwQZm0gqGMgS3X/KzKCgavCRTQ= 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-18-xIfk13HdOnaqeSW-BE0g3w-1; Tue, 18 Feb 2020 16:49:21 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A9FAC8010E5; Tue, 18 Feb 2020 21:49:16 +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 879225C1B0; Tue, 18 Feb 2020 21:49:16 +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 50DD935AFF; Tue, 18 Feb 2020 21:49:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01ILmu0F020632 for ; Tue, 18 Feb 2020 16:48:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7DB325C241; Tue, 18 Feb 2020 21:48:56 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from horse.redhat.com (unknown [10.18.25.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58E0F5C1B0; Tue, 18 Feb 2020 21:48:56 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id B85582257D9; Tue, 18 Feb 2020 16:48:52 -0500 (EST) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org, hch@infradead.org, dan.j.williams@intel.com Date: Tue, 18 Feb 2020 16:48:40 -0500 Message-Id: <20200218214841.10076-8-vgoyal@redhat.com> In-Reply-To: <20200218214841.10076-1-vgoyal@redhat.com> References: <20200218214841.10076-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: dm-devel@redhat.com Cc: vishal.l.verma@intel.com, dm-devel@redhat.com, Christoph Hellwig , vgoyal@redhat.com Subject: [dm-devel] [PATCH v5 7/8] dax, iomap: Start using dax native zero_page_range() 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.16 X-MC-Unique: xIfk13HdOnaqeSW-BE0g3w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Get rid of calling block device interface for zeroing in iomap dax zeroing path and use dax native zeroing interface instead. Suggested-by: Christoph Hellwig Reviewed-by: Christoph Hellwig Signed-off-by: Vivek Goyal --- fs/dax.c | 45 +++++++++------------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 35da144375a0..f8ae0a9984fa 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1038,48 +1038,21 @@ static vm_fault_t dax_load_hole(struct xa_state *xas, return ret; } -static bool dax_range_is_aligned(struct block_device *bdev, - unsigned int offset, unsigned int length) -{ - unsigned short sector_size = bdev_logical_block_size(bdev); - - if (!IS_ALIGNED(offset, sector_size)) - return false; - if (!IS_ALIGNED(length, sector_size)) - return false; - - return true; -} - int __dax_zero_page_range(struct block_device *bdev, struct dax_device *dax_dev, sector_t sector, unsigned int offset, unsigned int size) { - if (dax_range_is_aligned(bdev, offset, size)) { - sector_t start_sector = sector + (offset >> 9); - - return blkdev_issue_zeroout(bdev, start_sector, - size >> 9, GFP_NOFS, 0); - } else { - pgoff_t pgoff; - long rc, id; - void *kaddr; + pgoff_t pgoff; + long rc, id; - rc = bdev_dax_pgoff(bdev, sector, PAGE_SIZE, &pgoff); - if (rc) - return rc; + rc = bdev_dax_pgoff(bdev, sector, PAGE_SIZE, &pgoff); + if (rc) + return rc; - id = dax_read_lock(); - rc = dax_direct_access(dax_dev, pgoff, 1, &kaddr, NULL); - if (rc < 0) { - dax_read_unlock(id); - return rc; - } - memset(kaddr + offset, 0, size); - dax_flush(dax_dev, kaddr + offset, size); - dax_read_unlock(id); - } - return 0; + id = dax_read_lock(); + rc = dax_zero_page_range(dax_dev, (pgoff << PAGE_SHIFT) + offset, size); + dax_read_unlock(id); + return rc; } EXPORT_SYMBOL_GPL(__dax_zero_page_range);