From patchwork Thu Feb 7 00:03:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10800315 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 79F5713B4 for ; Thu, 7 Feb 2019 00:06:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 651A42D348 for ; Thu, 7 Feb 2019 00:06:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 597AC2D5C8; Thu, 7 Feb 2019 00:06:53 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (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 BED672D348 for ; Thu, 7 Feb 2019 00:06:52 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 38B264C3B79; Wed, 6 Feb 2019 16:06:50 -0800 (PST) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 9885B4C3B79 for ; Wed, 6 Feb 2019 16:06:47 -0800 (PST) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id DAB60AE5E; Thu, 7 Feb 2019 00:06:46 +0000 (UTC) From: NeilBrown To: Andreas Dilger , James Simmons , Oleg Drokin Date: Thu, 07 Feb 2019 11:03:33 +1100 Message-ID: <154949781310.10620.8883358407999258821.stgit@noble.brown> In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 10/21] lustre: obdclass: use cl_object_for_each where appropriate X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP There are various places which have a list_for_each_entry() where cl_object_for_each (or .._reverse) is more appropriate. Several of these re-use the 'obj' function parameter as a loop iterator, which is a little confusing. Change these to use cl_object_for_each{_reverse}, and where needed, introduce a new iterator variable 'o'. Signed-off-by: NeilBrown Signed-off-by: NeilBrown Reviewed-by: James Simmons Reviewed-by: James Simmons Reviewed-by: Andreas Dilger --- drivers/staging/lustre/lustre/lov/lov_page.c | 3 - drivers/staging/lustre/lustre/obdclass/cl_lock.c | 3 - drivers/staging/lustre/lustre/obdclass/cl_object.c | 82 +++++++++----------- drivers/staging/lustre/lustre/obdclass/cl_page.c | 11 +-- 4 files changed, 44 insertions(+), 55 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c index 08485a95ec01..e64b350601d2 100644 --- a/drivers/staging/lustre/lustre/lov/lov_page.c +++ b/drivers/staging/lustre/lustre/lov/lov_page.c @@ -103,8 +103,7 @@ int lov_page_init_composite(const struct lu_env *env, struct cl_object *obj, return PTR_ERR(sub); subobj = lovsub2cl(r0->lo_sub[stripe]); - list_for_each_entry(o, &subobj->co_lu.lo_header->loh_layers, - co_lu.lo_linkage) { + cl_object_for_each(o, subobj) { if (o->co_ops->coo_page_init) { rc = o->co_ops->coo_page_init(sub->sub_env, o, page, cl_index(subobj, suboff)); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index 8133d992cc73..fc5976d8b37b 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -103,8 +103,7 @@ int cl_lock_init(const struct lu_env *env, struct cl_lock *lock, LASSERT(obj); INIT_LIST_HEAD(&lock->cll_layers); - list_for_each_entry(scan, &obj->co_lu.lo_header->loh_layers, - co_lu.lo_linkage) { + cl_object_for_each(scan, obj) { result = scan->co_ops->coo_lock_init(env, scan, lock, io); if (result != 0) { cl_lock_fini(env, lock); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index f724b2d62df1..d71a680660da 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -190,16 +190,15 @@ EXPORT_SYMBOL(cl_object_attr_unlock); int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, struct cl_attr *attr) { - struct lu_object_header *top; + struct cl_object *o; int result; assert_spin_locked(cl_object_attr_guard(obj)); - top = obj->co_lu.lo_header; result = 0; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_attr_get) { - result = obj->co_ops->coo_attr_get(env, obj, attr); + cl_object_for_each(o, obj) { + if (o->co_ops->coo_attr_get) { + result = o->co_ops->coo_attr_get(env, o, attr); if (result != 0) { if (result > 0) result = 0; @@ -221,17 +220,16 @@ EXPORT_SYMBOL(cl_object_attr_get); int cl_object_attr_update(const struct lu_env *env, struct cl_object *obj, const struct cl_attr *attr, unsigned int v) { - struct lu_object_header *top; + struct cl_object *o; int result; assert_spin_locked(cl_object_attr_guard(obj)); - top = obj->co_lu.lo_header; result = 0; - list_for_each_entry_reverse(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_attr_update) { - result = obj->co_ops->coo_attr_update(env, obj, attr, - v); + cl_object_for_each_reverse(o, obj) { + if (o->co_ops->coo_attr_update) { + result = o->co_ops->coo_attr_update(env, o, attr, + v); if (result != 0) { if (result > 0) result = 0; @@ -254,19 +252,18 @@ EXPORT_SYMBOL(cl_object_attr_update); int cl_object_glimpse(const struct lu_env *env, struct cl_object *obj, struct ost_lvb *lvb) { - struct lu_object_header *top; + struct cl_object *o; int result; - top = obj->co_lu.lo_header; result = 0; - list_for_each_entry_reverse(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_glimpse) { - result = obj->co_ops->coo_glimpse(env, obj, lvb); + cl_object_for_each_reverse(o, obj) { + if (o->co_ops->coo_glimpse) { + result = o->co_ops->coo_glimpse(env, o, lvb); if (result != 0) break; } } - LU_OBJECT_HEADER(D_DLMTRACE, env, lu_object_top(top), + LU_OBJECT_HEADER(D_DLMTRACE, env, lu_object_top(obj->co_lu.lo_header), "size: %llu mtime: %llu atime: %llu ctime: %llu blocks: %llu\n", lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks); @@ -280,14 +277,13 @@ EXPORT_SYMBOL(cl_object_glimpse); int cl_conf_set(const struct lu_env *env, struct cl_object *obj, const struct cl_object_conf *conf) { - struct lu_object_header *top; + struct cl_object *o; int result; - top = obj->co_lu.lo_header; result = 0; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_conf_set) { - result = obj->co_ops->coo_conf_set(env, obj, conf); + cl_object_for_each(o, obj) { + if (o->co_ops->coo_conf_set) { + result = o->co_ops->coo_conf_set(env, o, conf); if (result != 0) break; } @@ -301,13 +297,11 @@ EXPORT_SYMBOL(cl_conf_set); */ int cl_object_prune(const struct lu_env *env, struct cl_object *obj) { - struct lu_object_header *top; struct cl_object *o; int result; - top = obj->co_lu.lo_header; result = 0; - list_for_each_entry(o, &top->loh_layers, co_lu.lo_linkage) { + cl_object_for_each(o, obj) { if (o->co_ops->coo_prune) { result = o->co_ops->coo_prune(env, o); if (result != 0) @@ -325,14 +319,13 @@ EXPORT_SYMBOL(cl_object_prune); int cl_object_getstripe(const struct lu_env *env, struct cl_object *obj, struct lov_user_md __user *uarg, size_t size) { - struct lu_object_header *top; + struct cl_object *o; int result = 0; - top = obj->co_lu.lo_header; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_getstripe) { - result = obj->co_ops->coo_getstripe(env, obj, uarg, - size); + cl_object_for_each(o, obj) { + if (o->co_ops->coo_getstripe) { + result = o->co_ops->coo_getstripe(env, o, uarg, + size); if (result) break; } @@ -357,14 +350,13 @@ int cl_object_fiemap(const struct lu_env *env, struct cl_object *obj, struct ll_fiemap_info_key *key, struct fiemap *fiemap, size_t *buflen) { - struct lu_object_header *top; + struct cl_object *o; int result = 0; - top = obj->co_lu.lo_header; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_fiemap) { - result = obj->co_ops->coo_fiemap(env, obj, key, fiemap, - buflen); + cl_object_for_each(o, obj) { + if (o->co_ops->coo_fiemap) { + result = o->co_ops->coo_fiemap(env, o, key, fiemap, + buflen); if (result) break; } @@ -376,11 +368,11 @@ EXPORT_SYMBOL(cl_object_fiemap); int cl_object_layout_get(const struct lu_env *env, struct cl_object *obj, struct cl_layout *cl) { - struct lu_object_header *top = obj->co_lu.lo_header; + struct cl_object *o; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_layout_get) - return obj->co_ops->coo_layout_get(env, obj, cl); + cl_object_for_each(o, obj) { + if (o->co_ops->coo_layout_get) + return o->co_ops->coo_layout_get(env, o, cl); } return -EOPNOTSUPP; @@ -389,12 +381,12 @@ EXPORT_SYMBOL(cl_object_layout_get); loff_t cl_object_maxbytes(struct cl_object *obj) { - struct lu_object_header *top = obj->co_lu.lo_header; + struct cl_object *o; loff_t maxbytes = LLONG_MAX; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_maxbytes) - maxbytes = min_t(loff_t, obj->co_ops->coo_maxbytes(obj), + cl_object_for_each(o, obj) { + if (o->co_ops->coo_maxbytes) + maxbytes = min_t(loff_t, o->co_ops->coo_maxbytes(o), maxbytes); } diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index 057318deaa4e..7d00a9233a3b 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -132,7 +132,7 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, enum cl_page_type type) { struct cl_page *page; - struct lu_object_header *head; + struct cl_object *o2; page = kzalloc(cl_object_header(o)->coh_page_bufsize, GFP_NOFS); if (page) { @@ -149,11 +149,10 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, INIT_LIST_HEAD(&page->cp_layers); INIT_LIST_HEAD(&page->cp_batch); lu_ref_init(&page->cp_reference); - head = o->co_lu.lo_header; - list_for_each_entry(o, &head->loh_layers, co_lu.lo_linkage) { - if (o->co_ops->coo_page_init) { - result = o->co_ops->coo_page_init(env, o, page, - ind); + cl_object_for_each(o2, o) { + if (o2->co_ops->coo_page_init) { + result = o2->co_ops->coo_page_init(env, o2, page, + ind); if (result != 0) { __cl_page_delete(env, page); cl_page_free(env, page);