From patchwork Mon Jun 11 14:06:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10458023 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 329376020F for ; Mon, 11 Jun 2018 14:12:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A99828912 for ; Mon, 11 Jun 2018 14:12:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06DCD28591; Mon, 11 Jun 2018 14:12:28 +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=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08C8E28912 for ; Mon, 11 Jun 2018 14:11:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF5436B029F; Mon, 11 Jun 2018 10:07:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A7D1D6B02A0; Mon, 11 Jun 2018 10:07:13 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A9196B02A1; Mon, 11 Jun 2018 10:07:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f69.google.com (mail-pl0-f69.google.com [209.85.160.69]) by kanga.kvack.org (Postfix) with ESMTP id 3E0EE6B029F for ; Mon, 11 Jun 2018 10:07:13 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id 89-v6so12104585plb.18 for ; Mon, 11 Jun 2018 07:07:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=ujfYxZIIK99WfZRI1IdMsLLKISMVlB52o41m2OWnoI8=; b=s9P1WLJsgngFu/zHfePaiMbRjgZ0ePDb8UQGq0WqDh0orPbe7f8F4WnRlrzeR4kYxh w/gpYjPDjhWatmwDRQyvAG0AX32sbl5NxeAYk7nBiRUJWytZGkHyOYtyzwuIDH9wnPIJ n8lVgnNowWBbIoqSDGWj2W38Y7tqbU99AZYiy/nylN0VvsWRnrL0c0KoYIvY97FHoo5u 3lR4ffbys5fxjw/6h1VuAmAacjqiuAM/wAW27Mx5QIBi3TyxI1MMQjxP5dfF35pULKlf 53p7smSuPtB8bWy0NSr7rBIUNLSLqK+HGyidYI2RZf5i4skJSCkth76k4dS74Os5Jj97 V0Jw== X-Gm-Message-State: APt69E3SASlYFgRta15KRjONrhjJcp4W0lDdH7cuk2RgpI5MsifYfPa8 byNy6YBUAflGFUcsiP5XUppviNhwNxXUUMfbNfA6EFTABT5a+6SN32VPu+S7YTwKRtxyRBpDLiH 8wEaCOBQO0+0K5+UCFJ24AlI7XzI9+JHDlg8WfTbY2wx+P4vKy93kskIU0xp3jAIKFA== X-Received: by 2002:a17:902:4c88:: with SMTP id b8-v6mr18261813ple.285.1528726032943; Mon, 11 Jun 2018 07:07:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKINuhbMJJC6RViA78ummVqeEB6CN7V6aayGOs4KK3qxrqKRX/XjKav69IuVYvb/SlPmmaBT X-Received: by 2002:a17:902:4c88:: with SMTP id b8-v6mr18261753ple.285.1528726031972; Mon, 11 Jun 2018 07:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528726031; cv=none; d=google.com; s=arc-20160816; b=KTSxYGgfhN39Zp7lvc1kgeQYuqiWwQrRQZ1kFcN4r1C/UZ/EyVLTMdvz3PA4gRg7Eq uVbcrnFes334eQYFL6BJzH/GCo2kMoY2AUZJ8RqSvAZZZQ0zbZG/PSFRm8WQee53AtLx YYMMbqaPf9lrIXpBmnV+MLlR34sRSfC+2ycZHkwgwpuJ6cjBdSY1lqrWAuIli1Bc/dzd zwjME8QhISkiOls1RVSKhZq+jNt5ReJYqS2HP4lyxkQ85mgesRcbjLGDMSycf0bbx/NI 32+kCuEmpnhs23+xvb3VUgJqGvz5e8QnPoCeNA0Or8YhUtVdTGy1YgO5oPGvhzlhO3Ho A/DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ujfYxZIIK99WfZRI1IdMsLLKISMVlB52o41m2OWnoI8=; b=Hr/gf90TPbh7r2ZEDYLhQplGLkR3HqBRtfNyVAE9yKaYR+xWhcDK31wWEQ0StZVwGI zjDYRt1a7//WsqBlsqS4PjslrzZeCsIqaUzLpes/WcNU/voDdiQF4BVdeS8U5UFr/7eL bL9FUdQms16KvS+nEfqiOU7zFfWiXw5Y7Gun4YxXiusaXzfW0ZR21ePtqoVScLUeAOKr Sz7xt7vSBH08l5Dt/F7FzBS40lP90adWV+pdPiYW0zILNZ5SX4ysB0hz4O+JYyvH/A+E oywl3i3FG8L5aNOti1H+qVuhnKihdDT3RAk0X6HcmWrqGpp1uzgxCfwOILRkfTFRNNqn 3sKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=jFggEjEK; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id f20-v6si35558602pgn.464.2018.06.11.07.07.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 07:07:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=jFggEjEK; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ujfYxZIIK99WfZRI1IdMsLLKISMVlB52o41m2OWnoI8=; b=jFggEjEKsiE60Ti2L72G3uyKP hHWplrkGm5THJgbvekX2XemUx1GMPanxUVs7+xMyCG25tCDRz1bmBDRgY2nX1jj6FYD+jSbufkK1P 1F9x/SWvTIwTlMgOtT5pGGiILTP3CXI403Ns7h6VokvSxu2lkAw1fy+s0Rs/iVGuSw7l890KWzKIx R7NXCaOZ8wjAS2Jan/JDe2a+ja99sJTmeLq6ysSHpzbRIY9cUUzVHZ2tZrayme51JnnXYTXz79ZW2 7YHOFtJu1nUCHDWgtjJoSsQW4zfDsTOxU8mAWPX6/ZI7XWzkX/rMASel2j427KcAXPPZaqX/HfGYi ChZu++RRg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSNTS-00050G-J3; Mon, 11 Jun 2018 14:07:10 +0000 From: Matthew Wilcox To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox , Jan Kara , Jeff Layton , Lukas Czerner , Ross Zwisler , Christoph Hellwig , Goldwyn Rodrigues , Nicholas Piggin , Ryusuke Konishi , linux-nilfs@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH v13 62/72] dax: Hash on XArray instead of mapping Date: Mon, 11 Jun 2018 07:06:29 -0700 Message-Id: <20180611140639.17215-63-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180611140639.17215-1-willy@infradead.org> References: <20180611140639.17215-1-willy@infradead.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Matthew Wilcox Since the XArray is embedded in the struct address_space, its address contains exactly as much entropy as the address of the mapping. This patch is purely preparatory for later patches which will simplify the wait/wake interfaces. Signed-off-by: Matthew Wilcox --- fs/dax.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 97e8931541f1..7d0712c45da5 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -116,7 +116,7 @@ static int dax_is_empty_entry(void *entry) * DAX page cache entry locking */ struct exceptional_entry_key { - struct address_space *mapping; + struct xarray *xa; pgoff_t entry_start; }; @@ -125,7 +125,7 @@ struct wait_exceptional_entry_queue { struct exceptional_entry_key key; }; -static wait_queue_head_t *dax_entry_waitqueue(struct address_space *mapping, +static wait_queue_head_t *dax_entry_waitqueue(struct xarray *xa, pgoff_t index, void *entry, struct exceptional_entry_key *key) { unsigned long hash; @@ -138,21 +138,21 @@ static wait_queue_head_t *dax_entry_waitqueue(struct address_space *mapping, if (dax_is_pmd_entry(entry)) index &= ~PG_PMD_COLOUR; - key->mapping = mapping; + key->xa = xa; key->entry_start = index; - hash = hash_long((unsigned long)mapping ^ index, DAX_WAIT_TABLE_BITS); + hash = hash_long((unsigned long)xa ^ index, DAX_WAIT_TABLE_BITS); return wait_table + hash; } -static int wake_exceptional_entry_func(wait_queue_entry_t *wait, unsigned int mode, - int sync, void *keyp) +static int wake_exceptional_entry_func(wait_queue_entry_t *wait, + unsigned int mode, int sync, void *keyp) { struct exceptional_entry_key *key = keyp; struct wait_exceptional_entry_queue *ewait = container_of(wait, struct wait_exceptional_entry_queue, wait); - if (key->mapping != ewait->key.mapping || + if (key->xa != ewait->key.xa || key->entry_start != ewait->key.entry_start) return 0; return autoremove_wake_function(wait, mode, sync, NULL); @@ -163,13 +163,13 @@ static int wake_exceptional_entry_func(wait_queue_entry_t *wait, unsigned int mo * The important information it's conveying is whether the entry at * this index used to be a PMD entry. */ -static void dax_wake_mapping_entry_waiter(struct address_space *mapping, +static void dax_wake_mapping_entry_waiter(struct xarray *xa, pgoff_t index, void *entry, bool wake_all) { struct exceptional_entry_key key; wait_queue_head_t *wq; - wq = dax_entry_waitqueue(mapping, index, entry, &key); + wq = dax_entry_waitqueue(xa, index, entry, &key); /* * Checking for locked entry and prepare_to_wait_exclusive() happens @@ -246,7 +246,8 @@ static void *get_unlocked_mapping_entry(struct address_space *mapping, return entry; } - wq = dax_entry_waitqueue(mapping, index, entry, &ewait.key); + wq = dax_entry_waitqueue(&mapping->i_pages, index, entry, + &ewait.key); prepare_to_wait_exclusive(wq, &ewait.wait, TASK_UNINTERRUPTIBLE); xa_unlock_irq(&mapping->i_pages); @@ -270,7 +271,7 @@ static void dax_unlock_mapping_entry(struct address_space *mapping, } unlock_slot(mapping, slot); xa_unlock_irq(&mapping->i_pages); - dax_wake_mapping_entry_waiter(mapping, index, entry, false); + dax_wake_mapping_entry_waiter(&mapping->i_pages, index, entry, false); } static void put_locked_mapping_entry(struct address_space *mapping, @@ -290,7 +291,7 @@ static void put_unlocked_mapping_entry(struct address_space *mapping, return; /* We have to wake up next waiter for the page cache entry lock */ - dax_wake_mapping_entry_waiter(mapping, index, entry, false); + dax_wake_mapping_entry_waiter(&mapping->i_pages, index, entry, false); } static unsigned long dax_entry_size(void *entry) @@ -481,8 +482,8 @@ static void *grab_mapping_entry(struct address_space *mapping, pgoff_t index, dax_disassociate_entry(entry, mapping, false); radix_tree_delete(&mapping->i_pages, index); mapping->nrexceptional--; - dax_wake_mapping_entry_waiter(mapping, index, entry, - true); + dax_wake_mapping_entry_waiter(&mapping->i_pages, + index, entry, true); } entry = dax_make_locked(0, size_flag | DAX_EMPTY);