Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4234894imm; Mon, 11 Jun 2018 09:02:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIn0koToQhqAxsHqDA6hFKJZ6M4OPsX6DLohZL2ZZydb5/kUZi2q8CsauSKLoo+3opgIuPu X-Received: by 2002:a17:902:5602:: with SMTP id h2-v6mr14651861pli.314.1528732945810; Mon, 11 Jun 2018 09:02:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528732945; cv=none; d=google.com; s=arc-20160816; b=UuRTMqccj/g60FtHjJnwuglOZe1/zkYH0fUCQ3B9ITzs/ptKy2Z0qGA3Pce9pq/gLG r1XGKp+//45pn+mS0UklJm1ZsHSAIyodmGqE5WBscjChMKPLDR14EWITJ7Sn6+ui5sWC 1XRi7t57DtVbAIme8cGVw78yOu+bkXwcgu/arhNX5RtKZG21WlYfUN+mL8sFLtrErCCU Oz1FTdVHfpGd6Hwgp5+QZXrrMgPavZhhGArh7EOQ5bOl3hyZmvnb93eeZzS73eIm0IUy YQIA33VRotlAAYNPoLt3TZRZs7IcIzbDPohiLk4xSxZM6yZW1LnEkPlVNrfWjjHwbDHk fcow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=rjHUJTTQC6xMfhF+XWu1NEuTxvlVO1pnsA+PiPK/GIM=; b=wyHqy/rc7nwyXK9Qvk+UUxe1KNMh49Ba6NcFxIWxcJlLczBBJyeeQqi7dtbw4uu+FE L0tRDEGx4LZyCrtigWqXYIwpVGnScErIwStuOYhD7+Qz1V++qsPVsfsU2q4A8t1XEMVH 8KLejzJq7nELf+GoBsREsoOYbqT3ZfW6VWM8eH7qJLLC5VhHKljFGLf0K7pv296YYv32 yI7y8ubIwMo8WXZv5VbWZoFr8I5nB13Zp4rViUno7y7h9QT62brZZst+DkSzPEb0kjkv 9/FGkKvV3Dng6wpqWQTP9d5bLicYqNU0CMOtGJwX4OLqwEow8mgfI9+6DnLU0UNLohm5 yw+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=d459D/BI; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w5-v6si5116735plz.438.2018.06.11.09.02.10; Mon, 11 Jun 2018 09:02:25 -0700 (PDT) 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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=d459D/BI; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933726AbeFKOHY (ORCPT + 99 others); Mon, 11 Jun 2018 10:07:24 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:46424 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933622AbeFKOHJ (ORCPT ); Mon, 11 Jun 2018 10:07:09 -0400 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=rjHUJTTQC6xMfhF+XWu1NEuTxvlVO1pnsA+PiPK/GIM=; b=d459D/BINZ/8hQdtBQgjnZTqe 8B0BFn+rP17lb2ql24O2/PQ2ziqsZyQpfNTrJ7K0IbkbjUZU8aiz3uPOvVUMCpyhlpAqFibipyRdV jKWPIfmcqxArCJHWPA9XqlUXDNDxoCmCZMaEy1X4eJkR1vXwiUZMEkl2vWwD1/FgkqThaaBTnR3SE f3Ga9cGj+u/hXikWei6NcT+CmiT3dIomCL73a5p0YD/DHp5+u+vvShYEYiGsAETSGW91dcPpjb2SW fXjkF4tAG0tF1nzjDkiHFt4YmiKsLW4TSCSIJSkCImp5/oGEogPP6AUngN/xnxbq9QTE0cETBp4iN gp8Ie5tnQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSNTQ-0004xZ-9L; Mon, 11 Jun 2018 14:07:08 +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 58/72] fs: Convert writeback to XArray Date: Mon, 11 Jun 2018 07:06:25 -0700 Message-Id: <20180611140639.17215-59-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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox A couple of short loops. Signed-off-by: Matthew Wilcox --- fs/fs-writeback.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 471d863958bc..137f241a3ee3 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -339,9 +339,9 @@ static void inode_switch_wbs_work_fn(struct work_struct *work) struct address_space *mapping = inode->i_mapping; struct bdi_writeback *old_wb = inode->i_wb; struct bdi_writeback *new_wb = isw->new_wb; - struct radix_tree_iter iter; + XA_STATE(xas, &mapping->i_pages, 0); + struct page *page; bool switched = false; - void **slot; /* * By the time control reaches here, RCU grace period has passed @@ -375,25 +375,18 @@ static void inode_switch_wbs_work_fn(struct work_struct *work) * to possibly dirty pages while PAGECACHE_TAG_WRITEBACK points to * pages actually under writeback. */ - radix_tree_for_each_tagged(slot, &mapping->i_pages, &iter, 0, - PAGECACHE_TAG_DIRTY) { - struct page *page = radix_tree_deref_slot_protected(slot, - &mapping->i_pages.xa_lock); - if (likely(page) && PageDirty(page)) { + xas_for_each_tagged(&xas, page, ULONG_MAX, PAGECACHE_TAG_DIRTY) { + if (PageDirty(page)) { dec_wb_stat(old_wb, WB_RECLAIMABLE); inc_wb_stat(new_wb, WB_RECLAIMABLE); } } - radix_tree_for_each_tagged(slot, &mapping->i_pages, &iter, 0, - PAGECACHE_TAG_WRITEBACK) { - struct page *page = radix_tree_deref_slot_protected(slot, - &mapping->i_pages.xa_lock); - if (likely(page)) { - WARN_ON_ONCE(!PageWriteback(page)); - dec_wb_stat(old_wb, WB_WRITEBACK); - inc_wb_stat(new_wb, WB_WRITEBACK); - } + xas_set(&xas, 0); + xas_for_each_tagged(&xas, page, ULONG_MAX, PAGECACHE_TAG_WRITEBACK) { + WARN_ON_ONCE(!PageWriteback(page)); + dec_wb_stat(old_wb, WB_WRITEBACK); + inc_wb_stat(new_wb, WB_WRITEBACK); } wb_get(new_wb); -- 2.17.1