From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bombadil.infradead.org ([65.50.211.133]:50577 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753380AbdLFAmP (ORCPT ); Tue, 5 Dec 2017 19:42:15 -0500 From: Matthew Wilcox Cc: Matthew Wilcox , Ross Zwisler , Jens Axboe , Rehas Sachdeva , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-nilfs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 56/73] lustre: Convert to XArray Date: Tue, 5 Dec 2017 16:41:42 -0800 Message-Id: <20171206004159.3755-57-willy@infradead.org> In-Reply-To: <20171206004159.3755-1-willy@infradead.org> References: <20171206004159.3755-1-willy@infradead.org> To: unlisted-recipients:; (no To-header on input) Sender: linux-btrfs-owner@vger.kernel.org List-ID: From: Matthew Wilcox Signed-off-by: Matthew Wilcox --- drivers/staging/lustre/lustre/llite/glimpse.c | 12 +++++------- drivers/staging/lustre/lustre/mdc/mdc_request.c | 16 ++++++++-------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/glimpse.c b/drivers/staging/lustre/lustre/llite/glimpse.c index 5f2843da911c..25232fdf5797 100644 --- a/drivers/staging/lustre/lustre/llite/glimpse.c +++ b/drivers/staging/lustre/lustre/llite/glimpse.c @@ -57,7 +57,7 @@ static const struct cl_lock_descr whole_file = { }; /* - * Check whether file has possible unwriten pages. + * Check whether file has possible unwritten pages. * * \retval 1 file is mmap-ed or has dirty pages * 0 otherwise @@ -66,16 +66,14 @@ blkcnt_t dirty_cnt(struct inode *inode) { blkcnt_t cnt = 0; struct vvp_object *vob = cl_inode2vvp(inode); - void *results[1]; - if (inode->i_mapping) - cnt += radix_tree_gang_lookup_tag(&inode->i_mapping->pages, - results, 0, 1, - PAGECACHE_TAG_DIRTY); + if (inode->i_mapping && xa_tagged(&inode->i_mapping->pages, + PAGECACHE_TAG_DIRTY)) + cnt = 1; if (cnt == 0 && atomic_read(&vob->vob_mmap_cnt) > 0) cnt = 1; - return (cnt > 0) ? 1 : 0; + return cnt; } int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 2ec79a6b17da..ea23247e9e02 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -934,17 +934,18 @@ static struct page *mdc_page_locate(struct address_space *mapping, __u64 *hash, * hash _smaller_ than one we are looking for. */ unsigned long offset = hash_x_index(*hash, hash64); + XA_STATE(xas, &mapping->pages, offset); struct page *page; - int found; - xa_lock_irq(&mapping->pages); - found = radix_tree_gang_lookup(&mapping->pages, - (void **)&page, offset, 1); - if (found > 0 && !xa_is_value(page)) { + xas_lock_irq(&xas); + page = xas_find(&xas, ULONG_MAX); + if (xa_is_value(page)) + page = NULL; + if (page) { struct lu_dirpage *dp; get_page(page); - xa_unlock_irq(&mapping->pages); + xas_unlock_irq(&xas); /* * In contrast to find_lock_page() we are sure that directory * page cannot be truncated (while DLM lock is held) and, @@ -992,8 +993,7 @@ static struct page *mdc_page_locate(struct address_space *mapping, __u64 *hash, page = ERR_PTR(-EIO); } } else { - xa_unlock_irq(&mapping->pages); - page = NULL; + xas_unlock_irq(&xas); } return page; } -- 2.15.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Matthew Wilcox To: Cc: Matthew Wilcox , Ross Zwisler , Jens Axboe , Rehas Sachdeva , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-nilfs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 56/73] lustre: Convert to XArray Date: Tue, 5 Dec 2017 16:41:42 -0800 Message-Id: <20171206004159.3755-57-willy@infradead.org> In-Reply-To: <20171206004159.3755-1-willy@infradead.org> References: <20171206004159.3755-1-willy@infradead.org> Sender: owner-linux-mm@kvack.org List-ID: From: Matthew Wilcox Signed-off-by: Matthew Wilcox --- drivers/staging/lustre/lustre/llite/glimpse.c | 12 +++++------- drivers/staging/lustre/lustre/mdc/mdc_request.c | 16 ++++++++-------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/glimpse.c b/drivers/staging/lustre/lustre/llite/glimpse.c index 5f2843da911c..25232fdf5797 100644 --- a/drivers/staging/lustre/lustre/llite/glimpse.c +++ b/drivers/staging/lustre/lustre/llite/glimpse.c @@ -57,7 +57,7 @@ static const struct cl_lock_descr whole_file = { }; /* - * Check whether file has possible unwriten pages. + * Check whether file has possible unwritten pages. * * \retval 1 file is mmap-ed or has dirty pages * 0 otherwise @@ -66,16 +66,14 @@ blkcnt_t dirty_cnt(struct inode *inode) { blkcnt_t cnt = 0; struct vvp_object *vob = cl_inode2vvp(inode); - void *results[1]; - if (inode->i_mapping) - cnt += radix_tree_gang_lookup_tag(&inode->i_mapping->pages, - results, 0, 1, - PAGECACHE_TAG_DIRTY); + if (inode->i_mapping && xa_tagged(&inode->i_mapping->pages, + PAGECACHE_TAG_DIRTY)) + cnt = 1; if (cnt == 0 && atomic_read(&vob->vob_mmap_cnt) > 0) cnt = 1; - return (cnt > 0) ? 1 : 0; + return cnt; } int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 2ec79a6b17da..ea23247e9e02 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -934,17 +934,18 @@ static struct page *mdc_page_locate(struct address_space *mapping, __u64 *hash, * hash _smaller_ than one we are looking for. */ unsigned long offset = hash_x_index(*hash, hash64); + XA_STATE(xas, &mapping->pages, offset); struct page *page; - int found; - xa_lock_irq(&mapping->pages); - found = radix_tree_gang_lookup(&mapping->pages, - (void **)&page, offset, 1); - if (found > 0 && !xa_is_value(page)) { + xas_lock_irq(&xas); + page = xas_find(&xas, ULONG_MAX); + if (xa_is_value(page)) + page = NULL; + if (page) { struct lu_dirpage *dp; get_page(page); - xa_unlock_irq(&mapping->pages); + xas_unlock_irq(&xas); /* * In contrast to find_lock_page() we are sure that directory * page cannot be truncated (while DLM lock is held) and, @@ -992,8 +993,7 @@ static struct page *mdc_page_locate(struct address_space *mapping, __u64 *hash, page = ERR_PTR(-EIO); } } else { - xa_unlock_irq(&mapping->pages); - page = NULL; + xas_unlock_irq(&xas); } return page; } -- 2.15.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bombadil.infradead.org ([65.50.211.133]:50577 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753380AbdLFAmP (ORCPT ); Tue, 5 Dec 2017 19:42:15 -0500 From: Matthew Wilcox Subject: [PATCH v4 56/73] lustre: Convert to XArray Date: Tue, 5 Dec 2017 16:41:42 -0800 Message-Id: <20171206004159.3755-57-willy@infradead.org> In-Reply-To: <20171206004159.3755-1-willy@infradead.org> References: <20171206004159.3755-1-willy@infradead.org> Sender: linux-xfs-owner@vger.kernel.org List-ID: List-Id: xfs Cc: Matthew Wilcox , Ross Zwisler , Jens Axboe , Rehas Sachdeva , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-nilfs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org From: Matthew Wilcox Signed-off-by: Matthew Wilcox --- drivers/staging/lustre/lustre/llite/glimpse.c | 12 +++++------- drivers/staging/lustre/lustre/mdc/mdc_request.c | 16 ++++++++-------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/glimpse.c b/drivers/staging/lustre/lustre/llite/glimpse.c index 5f2843da911c..25232fdf5797 100644 --- a/drivers/staging/lustre/lustre/llite/glimpse.c +++ b/drivers/staging/lustre/lustre/llite/glimpse.c @@ -57,7 +57,7 @@ static const struct cl_lock_descr whole_file = { }; /* - * Check whether file has possible unwriten pages. + * Check whether file has possible unwritten pages. * * \retval 1 file is mmap-ed or has dirty pages * 0 otherwise @@ -66,16 +66,14 @@ blkcnt_t dirty_cnt(struct inode *inode) { blkcnt_t cnt = 0; struct vvp_object *vob = cl_inode2vvp(inode); - void *results[1]; - if (inode->i_mapping) - cnt += radix_tree_gang_lookup_tag(&inode->i_mapping->pages, - results, 0, 1, - PAGECACHE_TAG_DIRTY); + if (inode->i_mapping && xa_tagged(&inode->i_mapping->pages, + PAGECACHE_TAG_DIRTY)) + cnt = 1; if (cnt == 0 && atomic_read(&vob->vob_mmap_cnt) > 0) cnt = 1; - return (cnt > 0) ? 1 : 0; + return cnt; } int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 2ec79a6b17da..ea23247e9e02 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -934,17 +934,18 @@ static struct page *mdc_page_locate(struct address_space *mapping, __u64 *hash, * hash _smaller_ than one we are looking for. */ unsigned long offset = hash_x_index(*hash, hash64); + XA_STATE(xas, &mapping->pages, offset); struct page *page; - int found; - xa_lock_irq(&mapping->pages); - found = radix_tree_gang_lookup(&mapping->pages, - (void **)&page, offset, 1); - if (found > 0 && !xa_is_value(page)) { + xas_lock_irq(&xas); + page = xas_find(&xas, ULONG_MAX); + if (xa_is_value(page)) + page = NULL; + if (page) { struct lu_dirpage *dp; get_page(page); - xa_unlock_irq(&mapping->pages); + xas_unlock_irq(&xas); /* * In contrast to find_lock_page() we are sure that directory * page cannot be truncated (while DLM lock is held) and, @@ -992,8 +993,7 @@ static struct page *mdc_page_locate(struct address_space *mapping, __u64 *hash, page = ERR_PTR(-EIO); } } else { - xa_unlock_irq(&mapping->pages); - page = NULL; + xas_unlock_irq(&xas); } return page; } -- 2.15.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id EAB6E6B02B4 for ; Tue, 5 Dec 2017 19:43:39 -0500 (EST) Received: by mail-pf0-f199.google.com with SMTP id e26so1614025pfi.15 for ; Tue, 05 Dec 2017 16:43:39 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id o1si903383pld.780.2017.12.05.16.42.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Dec 2017 16:42:14 -0800 (PST) From: Matthew Wilcox Subject: [PATCH v4 56/73] lustre: Convert to XArray Date: Tue, 5 Dec 2017 16:41:42 -0800 Message-Id: <20171206004159.3755-57-willy@infradead.org> In-Reply-To: <20171206004159.3755-1-willy@infradead.org> References: <20171206004159.3755-1-willy@infradead.org> Sender: owner-linux-mm@kvack.org List-ID: Cc: Matthew Wilcox , Ross Zwisler , Jens Axboe , Rehas Sachdeva , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-nilfs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org From: Matthew Wilcox Signed-off-by: Matthew Wilcox --- drivers/staging/lustre/lustre/llite/glimpse.c | 12 +++++------- drivers/staging/lustre/lustre/mdc/mdc_request.c | 16 ++++++++-------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/glimpse.c b/drivers/staging/lustre/lustre/llite/glimpse.c index 5f2843da911c..25232fdf5797 100644 --- a/drivers/staging/lustre/lustre/llite/glimpse.c +++ b/drivers/staging/lustre/lustre/llite/glimpse.c @@ -57,7 +57,7 @@ static const struct cl_lock_descr whole_file = { }; /* - * Check whether file has possible unwriten pages. + * Check whether file has possible unwritten pages. * * \retval 1 file is mmap-ed or has dirty pages * 0 otherwise @@ -66,16 +66,14 @@ blkcnt_t dirty_cnt(struct inode *inode) { blkcnt_t cnt = 0; struct vvp_object *vob = cl_inode2vvp(inode); - void *results[1]; - if (inode->i_mapping) - cnt += radix_tree_gang_lookup_tag(&inode->i_mapping->pages, - results, 0, 1, - PAGECACHE_TAG_DIRTY); + if (inode->i_mapping && xa_tagged(&inode->i_mapping->pages, + PAGECACHE_TAG_DIRTY)) + cnt = 1; if (cnt == 0 && atomic_read(&vob->vob_mmap_cnt) > 0) cnt = 1; - return (cnt > 0) ? 1 : 0; + return cnt; } int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 2ec79a6b17da..ea23247e9e02 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -934,17 +934,18 @@ static struct page *mdc_page_locate(struct address_space *mapping, __u64 *hash, * hash _smaller_ than one we are looking for. */ unsigned long offset = hash_x_index(*hash, hash64); + XA_STATE(xas, &mapping->pages, offset); struct page *page; - int found; - xa_lock_irq(&mapping->pages); - found = radix_tree_gang_lookup(&mapping->pages, - (void **)&page, offset, 1); - if (found > 0 && !xa_is_value(page)) { + xas_lock_irq(&xas); + page = xas_find(&xas, ULONG_MAX); + if (xa_is_value(page)) + page = NULL; + if (page) { struct lu_dirpage *dp; get_page(page); - xa_unlock_irq(&mapping->pages); + xas_unlock_irq(&xas); /* * In contrast to find_lock_page() we are sure that directory * page cannot be truncated (while DLM lock is held) and, @@ -992,8 +993,7 @@ static struct page *mdc_page_locate(struct address_space *mapping, __u64 *hash, page = ERR_PTR(-EIO); } } else { - xa_unlock_irq(&mapping->pages); - page = NULL; + xas_unlock_irq(&xas); } return page; } -- 2.15.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Wilcox Subject: [PATCH v4 56/73] lustre: Convert to XArray Date: Tue, 5 Dec 2017 16:41:42 -0800 Message-ID: <20171206004159.3755-57-willy@infradead.org> References: <20171206004159.3755-1-willy@infradead.org> Return-path: 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=R+W0RKPTSEy6wuuXlQ0BzPgxXVTQpHGfqPHXiJvqHnE=; b=BqdJR7iR1NjiJZsvFfJj2X6bh trykLu/6badO01+rux4Rv5E3ClOep5QN20xt3NW4KUhbqOOivkCSSO8vS3f0TlrjCFd0zdKyrqPf0 vpjcj2bag2UPCyWyBrjub7ievcfy4HzVPx0LfYO9RAbrtIV8IMhzg+Eg6UT6YN+vAaSHby30vgV1l 7OD6IeFCZX7tB9g5aeXWPXpjYjtU0Nem0PiSjlbFd1GAOOiTDZLoXOTzPcSuJ9eY5BWWTzskZ0fWN HFP7mNwEqDNjObX01KCqsUdgqWPDfX4gchrgt5Vo/6T3VELeLvpiuPw9SRSgjjiJhMYfPHf3sU0eC In-Reply-To: <20171206004159.3755-1-willy@infradead.org> Sender: linux-btrfs-owner@vger.kernel.org List-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Cc: Matthew Wilcox , Ross Zwisler , Jens Axboe , Rehas Sachdeva , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-nilfs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org From: Matthew Wilcox Signed-off-by: Matthew Wilcox --- drivers/staging/lustre/lustre/llite/glimpse.c | 12 +++++------- drivers/staging/lustre/lustre/mdc/mdc_request.c | 16 ++++++++-------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/glimpse.c b/drivers/staging/lustre/lustre/llite/glimpse.c index 5f2843da911c..25232fdf5797 100644 --- a/drivers/staging/lustre/lustre/llite/glimpse.c +++ b/drivers/staging/lustre/lustre/llite/glimpse.c @@ -57,7 +57,7 @@ static const struct cl_lock_descr whole_file = { }; /* - * Check whether file has possible unwriten pages. + * Check whether file has possible unwritten pages. * * \retval 1 file is mmap-ed or has dirty pages * 0 otherwise @@ -66,16 +66,14 @@ blkcnt_t dirty_cnt(struct inode *inode) { blkcnt_t cnt = 0; struct vvp_object *vob = cl_inode2vvp(inode); - void *results[1]; - if (inode->i_mapping) - cnt += radix_tree_gang_lookup_tag(&inode->i_mapping->pages, - results, 0, 1, - PAGECACHE_TAG_DIRTY); + if (inode->i_mapping && xa_tagged(&inode->i_mapping->pages, + PAGECACHE_TAG_DIRTY)) + cnt = 1; if (cnt == 0 && atomic_read(&vob->vob_mmap_cnt) > 0) cnt = 1; - return (cnt > 0) ? 1 : 0; + return cnt; } int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 2ec79a6b17da..ea23247e9e02 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -934,17 +934,18 @@ static struct page *mdc_page_locate(struct address_space *mapping, __u64 *hash, * hash _smaller_ than one we are looking for. */ unsigned long offset = hash_x_index(*hash, hash64); + XA_STATE(xas, &mapping->pages, offset); struct page *page; - int found; - xa_lock_irq(&mapping->pages); - found = radix_tree_gang_lookup(&mapping->pages, - (void **)&page, offset, 1); - if (found > 0 && !xa_is_value(page)) { + xas_lock_irq(&xas); + page = xas_find(&xas, ULONG_MAX); + if (xa_is_value(page)) + page = NULL; + if (page) { struct lu_dirpage *dp; get_page(page); - xa_unlock_irq(&mapping->pages); + xas_unlock_irq(&xas); /* * In contrast to find_lock_page() we are sure that directory * page cannot be truncated (while DLM lock is held) and, @@ -992,8 +993,7 @@ static struct page *mdc_page_locate(struct address_space *mapping, __u64 *hash, page = ERR_PTR(-EIO); } } else { - xa_unlock_irq(&mapping->pages); - page = NULL; + xas_unlock_irq(&xas); } return page; } -- 2.15.0