From patchwork Mon Dec 10 00:46:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10720449 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 9F003112E for ; Mon, 10 Dec 2018 00:47:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D25329D75 for ; Mon, 10 Dec 2018 00:47:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8171229D9D; Mon, 10 Dec 2018 00:47:18 +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 45EA629D75 for ; Mon, 10 Dec 2018 00:47:18 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id D6C8821F6C8; Sun, 9 Dec 2018 16:47:17 -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 4203521F6A2 for ; Sun, 9 Dec 2018 16:47:15 -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 5BE77AF16; Mon, 10 Dec 2018 00:47:14 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Mon, 10 Dec 2018 11:46:16 +1100 Message-ID: <154440277611.29887.14421165959542572417.stgit@noble> In-Reply-To: <154440246926.29887.1667505755325904791.stgit@noble> References: <154440246926.29887.1667505755325904791.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 1/4] lustre: lnet_startup_lndnet: avoid use-after-free 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 If lnet_startup_lndni() fails it will free 'ni'. So we mustn't de-reference it in the LASSERT() in that case. Signed-off-by: NeilBrown Reviewed-by: James Simmons --- drivers/staging/lustre/lnet/lnet/api-ni.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index fadd5d7f187a..6d528242acd9 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -1848,12 +1848,12 @@ lnet_startup_lndnet(struct lnet_net *net, struct lnet_lnd_tunables *tun) rc = lnet_startup_lndni(ni, tun); - LASSERT(ni->ni_net->net_tunables.lct_peer_timeout <= 0 || - ni->ni_net->net_lnd->lnd_query); - if (rc < 0) goto failed1; + LASSERT(ni->ni_net->net_tunables.lct_peer_timeout <= 0 || + ni->ni_net->net_lnd->lnd_query); + lnet_ni_addref(ni); list_add_tail(&ni->ni_netlist, &local_ni_list); From patchwork Mon Dec 10 00:46:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10720451 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 0776E112E for ; Mon, 10 Dec 2018 00:47:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA67D29D75 for ; Mon, 10 Dec 2018 00:47:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEEB229D9D; Mon, 10 Dec 2018 00:47:22 +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 9EB4D29D75 for ; Mon, 10 Dec 2018 00:47:22 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 5ABB821F669; Sun, 9 Dec 2018 16:47:22 -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 C52F521F5C4 for ; Sun, 9 Dec 2018 16:47:20 -0800 (PST) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C33BDAF31; Mon, 10 Dec 2018 00:47:19 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Mon, 10 Dec 2018 11:46:16 +1100 Message-ID: <154440277646.29887.1527233404610585779.stgit@noble> In-Reply-To: <154440246926.29887.1667505755325904791.stgit@noble> References: <154440246926.29887.1667505755325904791.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 2/4] lustre: use GFP_NOFS when lli_och_mutex is held - again 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 lockdep reports that lli_och_mutex is involved with fs_reclaim and is held during this memory allocation - so GFP_NOFS should be used to avoid a possible deadlock. This is a second place where this was a problem - I don't think there are more. Fixes: 0b0c8c1ca0bd ("lustre: llite: replace several GFP_NOFS with GFP_KERNEL") Signed-off-by: NeilBrown Signed-off-by: James Simmons Reviewed-by: James Simmons --- drivers/staging/lustre/lustre/llite/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 15910ff5f293..a6f149c47a7a 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -135,7 +135,7 @@ static int ll_close_inode_openhandle(struct inode *inode, goto out; } - op_data = kzalloc(sizeof(*op_data), GFP_KERNEL); + op_data = kzalloc(sizeof(*op_data), GFP_NOFS); /* * We leak openhandle and request here on error, but not much to be * done in OOM case since app won't retry close on error either. @@ -1652,7 +1652,7 @@ int ll_release_openhandle(struct inode *inode, struct lookup_intent *it) LASSERT(it_open_error(DISP_OPEN_OPEN, it) == 0); - och = kzalloc(sizeof(*och), GFP_KERNEL); + och = kzalloc(sizeof(*och), GFP_NOFS); if (!och) { rc = -ENOMEM; goto out; From patchwork Mon Dec 10 00:46:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10720453 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 96600112E for ; Mon, 10 Dec 2018 00:47:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85D3F29D75 for ; Mon, 10 Dec 2018 00:47:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A1A329D9D; Mon, 10 Dec 2018 00:47:29 +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 25B0E29D75 for ; Mon, 10 Dec 2018 00:47:29 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id C182221F69E; Sun, 9 Dec 2018 16:47:28 -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 3E02021F553 for ; Sun, 9 Dec 2018 16:47:26 -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 5320BAF5D; Mon, 10 Dec 2018 00:47:25 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Mon, 10 Dec 2018 11:46:16 +1100 Message-ID: <154440277667.29887.4836855598151465010.stgit@noble> In-Reply-To: <154440246926.29887.1667505755325904791.stgit@noble> References: <154440246926.29887.1667505755325904791.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 3/4] lustre: use bit-locking in echo_client. 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 The ep_lock used by echo client causes lockdep to complain. Multiple locks of the same class are taken concurrently which appear to lockdep to be prone to deadlocking, and can fill up lockdep's fixed size stack for locks. Ass ep_lock is taken on multiple pages always in ascending page order, deadlocks don't happen, so this is a false-positive. The function of the ep_lock is the same as thats for page_lock(), which is implemented as a bit-lock using wait_on_bit(). lockdep cannot see these locks, and doesn't really need to. So convert ep_lock to a simple bit-lock using wait_on_bit for waiting. This provides similar functionality, matches how page_lock() works, and avoids lockdep problems. Signed-off-by: NeilBrown Reviewed-by: James Simmons --- .../staging/lustre/lustre/obdecho/echo_client.c | 29 +++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 1ddb4a6dd8f3..887df7ce6b5c 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -78,7 +78,7 @@ struct echo_object_conf { struct echo_page { struct cl_page_slice ep_cl; - struct mutex ep_lock; + unsigned long ep_lock; }; struct echo_lock { @@ -217,10 +217,13 @@ static int echo_page_own(const struct lu_env *env, { struct echo_page *ep = cl2echo_page(slice); - if (!nonblock) - mutex_lock(&ep->ep_lock); - else if (!mutex_trylock(&ep->ep_lock)) - return -EAGAIN; + if (nonblock) { + if (test_and_set_bit(0, &ep->ep_lock)) + return -EAGAIN; + } else { + while (test_and_set_bit(0, &ep->ep_lock)) + wait_on_bit(&ep->ep_lock, 0, TASK_UNINTERRUPTIBLE); + } return 0; } @@ -230,8 +233,8 @@ static void echo_page_disown(const struct lu_env *env, { struct echo_page *ep = cl2echo_page(slice); - LASSERT(mutex_is_locked(&ep->ep_lock)); - mutex_unlock(&ep->ep_lock); + LASSERT(test_bit(0, &ep->ep_lock)); + clear_and_wake_up_bit(0, &ep->ep_lock); } static void echo_page_discard(const struct lu_env *env, @@ -244,7 +247,7 @@ static void echo_page_discard(const struct lu_env *env, static int echo_page_is_vmlocked(const struct lu_env *env, const struct cl_page_slice *slice) { - if (mutex_is_locked(&cl2echo_page(slice)->ep_lock)) + if (test_bit(0, &cl2echo_page(slice)->ep_lock)) return -EBUSY; return -ENODATA; } @@ -279,7 +282,7 @@ static int echo_page_print(const struct lu_env *env, struct echo_page *ep = cl2echo_page(slice); (*printer)(env, cookie, LUSTRE_ECHO_CLIENT_NAME "-page@%p %d vm@%p\n", - ep, mutex_is_locked(&ep->ep_lock), + ep, test_bit(0, &ep->ep_lock), slice->cpl_page->cp_vmpage); return 0; } @@ -339,7 +342,13 @@ static int echo_page_init(const struct lu_env *env, struct cl_object *obj, struct echo_object *eco = cl2echo_obj(obj); get_page(page->cp_vmpage); - mutex_init(&ep->ep_lock); + /* + * ep_lock is similar to the lock_page() lock, and + * cannot usefully be monitored by lockdep. + * So just a bit in an "unsigned long" and use the + * wait_on_bit() interface to wait for the bit to be clera. + */ + ep->ep_lock = 0; cl_page_slice_add(page, &ep->ep_cl, obj, index, &echo_page_ops); atomic_inc(&eco->eo_npages); return 0; From patchwork Mon Dec 10 00:46:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10720455 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 9E5DA112E for ; Mon, 10 Dec 2018 00:47:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89F5C29D95 for ; Mon, 10 Dec 2018 00:47:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D95A29DA2; Mon, 10 Dec 2018 00:47:35 +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 691CC29D95 for ; Mon, 10 Dec 2018 00:47:34 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 2F73F21F7EB; Sun, 9 Dec 2018 16:47:34 -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 4913421F5C4 for ; Sun, 9 Dec 2018 16:47:32 -0800 (PST) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4E136AEE9; Mon, 10 Dec 2018 00:47:31 +0000 (UTC) From: NeilBrown To: James Simmons , Oleg Drokin , Andreas Dilger Date: Mon, 10 Dec 2018 11:46:16 +1100 Message-ID: <154440277682.29887.12055691371699460100.stgit@noble> In-Reply-To: <154440246926.29887.1667505755325904791.stgit@noble> References: <154440246926.29887.1667505755325904791.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 4/4] lustre: clear up white space in osc header files. 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 Also change /** to /*. In the kernel, /** should only be used for kernel-doc comments. Signed-off-by: NeilBrown Reviewed-by: James Simmons --- .../staging/lustre/lustre/osc/osc_cl_internal.h | 319 ++++++++++---------- drivers/staging/lustre/lustre/osc/osc_internal.h | 96 +++--- 2 files changed, 209 insertions(+), 206 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index 4b0180946134..077a2b183634 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -48,62 +48,63 @@ #include #include "osc_internal.h" -/** \defgroup osc osc +/* \defgroup osc osc * @{ */ struct osc_extent; -/** +/* * State maintained by osc layer for each IO context. */ struct osc_io { - /** super class */ - struct cl_io_slice oi_cl; - /** true if this io is lockless. */ + /* super class */ + struct cl_io_slice oi_cl; + /* true if this io is lockless. */ unsigned int oi_lockless:1, - /** true if this io is counted as active IO */ + /* true if this io is counted as active IO */ oi_is_active:1; - /** how many LRU pages are reserved for this IO */ + /* how many LRU pages are reserved for this IO */ unsigned long oi_lru_reserved; - /** active extents, we know how many bytes is going to be written, - * so having an active extent will prevent it from being fragmented + /* active extents, we know how many bytes is going to be + * written, so having an active extent will prevent it from + * being fragmented */ - struct osc_extent *oi_active; - /** partially truncated extent, we need to hold this extent to prevent - * page writeback from happening. + struct osc_extent *oi_active; + /* partially truncated extent, we need to hold this extent to + * prevent page writeback from happening. */ - struct osc_extent *oi_trunc; + struct osc_extent *oi_trunc; - /** write osc_lock for this IO, used by osc_extent_find(). */ - struct osc_lock *oi_write_osclock; - struct obdo oi_oa; + /* write osc_lock for this IO, used by osc_extent_find(). */ + struct osc_lock *oi_write_osclock; + struct obdo oi_oa; struct osc_async_cbargs { - bool opc_rpc_sent; - int opc_rc; + bool opc_rpc_sent; + int opc_rc; struct completion opc_sync; - } oi_cbarg; + } oi_cbarg; }; -/** +/* * State maintained by osc layer for the duration of a system call. */ struct osc_session { - struct osc_io os_io; + struct osc_io os_io; }; #define OTI_PVEC_SIZE 256 struct osc_thread_info { - struct ldlm_res_id oti_resname; + struct ldlm_res_id oti_resname; union ldlm_policy_data oti_policy; - struct cl_lock_descr oti_descr; - struct cl_attr oti_attr; - struct lustre_handle oti_handle; - struct cl_page_list oti_plist; + struct cl_lock_descr oti_descr; + struct cl_attr oti_attr; + struct lustre_handle oti_handle; + struct cl_page_list oti_plist; struct cl_io oti_io; void *oti_pvec[OTI_PVEC_SIZE]; - /** + /* * Fields used by cl_lock_discard_pages(). */ pgoff_t oti_next_index; @@ -114,44 +115,44 @@ struct osc_thread_info { }; struct osc_object { - struct cl_object oo_cl; - struct lov_oinfo *oo_oinfo; - /** + struct cl_object oo_cl; + struct lov_oinfo *oo_oinfo; + /* * True if locking against this stripe got -EUSERS. */ - int oo_contended; - unsigned long oo_contention_time; - /** + int oo_contended; + unsigned long oo_contention_time; + /* * used by the osc to keep track of what objects to build into rpcs. * Protected by client_obd->cli_loi_list_lock. */ - struct list_head oo_ready_item; - struct list_head oo_hp_ready_item; - struct list_head oo_write_item; - struct list_head oo_read_item; + struct list_head oo_ready_item; + struct list_head oo_hp_ready_item; + struct list_head oo_write_item; + struct list_head oo_read_item; - /** + /* * extent is a red black tree to manage (async) dirty pages. */ - struct rb_root oo_root; - /** + struct rb_root oo_root; + /* * Manage write(dirty) extents. */ - struct list_head oo_hp_exts; /* list of hp extents */ - struct list_head oo_urgent_exts; /* list of writeback extents */ - struct list_head oo_full_exts; + struct list_head oo_hp_exts; /* list of hp extents */ + struct list_head oo_urgent_exts; /* list of writeback extents */ + struct list_head oo_full_exts; - struct list_head oo_reading_exts; + struct list_head oo_reading_exts; - atomic_t oo_nr_reads; - atomic_t oo_nr_writes; + atomic_t oo_nr_reads; + atomic_t oo_nr_writes; - /** Protect extent tree. Will be used to protect + /* Protect extent tree. Will be used to protect * oo_{read|write}_pages soon. */ - spinlock_t oo_lock; + spinlock_t oo_lock; - /** + /* * Radix tree for caching pages */ struct radix_tree_root oo_tree; @@ -162,7 +163,7 @@ struct osc_object { spinlock_t oo_ol_spin; struct list_head oo_ol_list; - /** number of active IOs of this object */ + /* number of active IOs of this object */ atomic_t oo_nr_ios; wait_queue_head_t oo_io_waitq; }; @@ -207,7 +208,7 @@ enum osc_lock_state { OLS_CANCELLED }; -/** +/* * osc-private state of cl_lock. * * Interaction with DLM. @@ -250,37 +251,37 @@ enum osc_lock_state { * future. */ struct osc_lock { - struct cl_lock_slice ols_cl; - /** Internal lock to protect states, etc. */ - spinlock_t ols_lock; - /** Owner sleeps on this channel for state change */ - struct cl_sync_io *ols_owner; - /** waiting list for this lock to be cancelled */ - struct list_head ols_waiting_list; - /** wait entry of ols_waiting_list */ - struct list_head ols_wait_entry; - /** list entry for osc_object::oo_ol_list */ - struct list_head ols_nextlock_oscobj; - - /** underlying DLM lock */ - struct ldlm_lock *ols_dlmlock; - /** DLM flags with which osc_lock::ols_lock was enqueued */ - __u64 ols_flags; - /** osc_lock::ols_lock handle */ - struct lustre_handle ols_handle; - struct ldlm_enqueue_info ols_einfo; - enum osc_lock_state ols_state; - /** lock value block */ - struct ost_lvb ols_lvb; - - /** + struct cl_lock_slice ols_cl; + /* Internal lock to protect states, etc. */ + spinlock_t ols_lock; + /* Owner sleeps on this channel for state change */ + struct cl_sync_io *ols_owner; + /* waiting list for this lock to be cancelled */ + struct list_head ols_waiting_list; + /* wait entry of ols_waiting_list */ + struct list_head ols_wait_entry; + /* list entry for osc_object::oo_ol_list */ + struct list_head ols_nextlock_oscobj; + + /* underlying DLM lock */ + struct ldlm_lock *ols_dlmlock; + /* DLM flags with which osc_lock::ols_lock was enqueued */ + __u64 ols_flags; + /* osc_lock::ols_lock handle */ + struct lustre_handle ols_handle; + struct ldlm_enqueue_info ols_einfo; + enum osc_lock_state ols_state; + /* lock value block */ + struct ost_lvb ols_lvb; + + /* * true, if ldlm_lock_addref() was called against * osc_lock::ols_lock. This is used for sanity checking. * * \see osc_lock::ols_has_ref */ - unsigned ols_hold :1, - /** + unsigned ols_hold :1, + /* * this is much like osc_lock::ols_hold, except that this bit is * cleared _after_ reference in released in osc_lock_unuse(). This * fine distinction is needed because: @@ -295,13 +296,13 @@ struct osc_lock { * release lock reference (so that a flag is needed that is * cleared before ldlm_lock_decref() is called). */ - ols_has_ref:1, - /** + ols_has_ref:1, + /* * inherit the lockless attribute from top level cl_io. * If true, osc_lock_enqueue is able to tolerate the -EUSERS error. */ - ols_locklessable:1, - /** + ols_locklessable:1, + /* * if set, the osc_lock is a glimpse lock. For glimpse locks, we treat * the EVAVAIL error as tolerable, this will make upper logic happy * to wait all glimpse locks to each OSTs to be completed. @@ -309,53 +310,53 @@ struct osc_lock { * granted. * Glimpse lock should be destroyed immediately after use. */ - ols_glimpse:1, - /** + ols_glimpse:1, + /* * For async glimpse lock. */ - ols_agl:1; + ols_agl:1; }; -/** +/* * Page state private for osc layer. */ struct osc_page { - struct cl_page_slice ops_cl; - /** + struct cl_page_slice ops_cl; + /* * Page queues used by osc to detect when RPC can be formed. */ - struct osc_async_page ops_oap; - /** + struct osc_async_page ops_oap; + /* * An offset within page from which next transfer starts. This is used * by cl_page_clip() to submit partial page transfers. */ - int ops_from; - /** + int ops_from; + /* * An offset within page at which next transfer ends. * * \see osc_page::ops_from. */ - int ops_to; - /** + int ops_to; + /* * Boolean, true iff page is under transfer. Used for sanity checking. */ - unsigned ops_transfer_pinned:1, - /** + unsigned ops_transfer_pinned:1, + /* * in LRU? */ - ops_in_lru:1, - /** + ops_in_lru:1, + /* * Set if the page must be transferred with OBD_BRW_SRVLOCK. */ - ops_srvlock:1; - /** + ops_srvlock:1; + /* * lru page list. See osc_lru_{del|use}() in osc_page.c for usage. */ - struct list_head ops_lru; - /** + struct list_head ops_lru; + /* * Submit time - the time when the page is starting RPC. For debugging. */ - unsigned long ops_submit_time; + unsigned long ops_submit_time; }; extern struct kmem_cache *osc_lock_kmem; @@ -422,7 +423,7 @@ int osc_object_is_contended(struct osc_object *obj); int osc_lock_is_lockless(const struct osc_lock *olck); -/***************************************************************************** +/**************************************************************************** * * Accessors. * @@ -558,17 +559,17 @@ static inline int osc_io_srvlock(struct osc_io *oio) } enum osc_extent_state { - OES_INV = 0, /** extent is just initialized or destroyed */ - OES_ACTIVE = 1, /** process is using this extent */ - OES_CACHE = 2, /** extent is ready for IO */ - OES_LOCKING = 3, /** locking page to prepare IO */ - OES_LOCK_DONE = 4, /** locking finished, ready to send */ - OES_RPC = 5, /** in RPC */ - OES_TRUNC = 6, /** being truncated */ + OES_INV = 0, /* extent is just initialized or destroyed */ + OES_ACTIVE = 1, /* process is using this extent */ + OES_CACHE = 2, /* extent is ready for IO */ + OES_LOCKING = 3, /* locking page to prepare IO */ + OES_LOCK_DONE = 4, /* locking finished, ready to send */ + OES_RPC = 5, /* in RPC */ + OES_TRUNC = 6, /* being truncated */ OES_STATE_MAX }; -/** +/* * osc_extent data to manage dirty pages. * osc_extent has the following attributes: * 1. all pages in the same must be in one RPC in write back; @@ -584,85 +585,85 @@ enum osc_extent_state { * page lock -> cl_loi_list_lock -> object lock(osc_object::oo_lock) */ struct osc_extent { - /** red-black tree node */ - struct rb_node oe_node; - /** osc_object of this extent */ - struct osc_object *oe_obj; - /** refcount, removed from red-black tree if reaches zero. */ - atomic_t oe_refc; - /** busy if non-zero */ - atomic_t oe_users; - /** link list of osc_object's oo_{hp|urgent|locking}_exts. */ - struct list_head oe_link; - /** state of this extent */ + /* red-black tree node */ + struct rb_node oe_node; + /* osc_object of this extent */ + struct osc_object *oe_obj; + /* refcount, removed from red-black tree if reaches zero. */ + atomic_t oe_refc; + /* busy if non-zero */ + atomic_t oe_users; + /* link list of osc_object's oo_{hp|urgent|locking}_exts. */ + struct list_head oe_link; + /* state of this extent */ enum osc_extent_state oe_state; - /** flags for this extent. */ - unsigned int oe_intree:1, - /** 0 is write, 1 is read */ - oe_rw:1, - /** sync extent, queued by osc_queue_sync_pages() */ + /* flags for this extent. */ + unsigned int oe_intree:1, + /* 0 is write, 1 is read */ + oe_rw:1, + /* sync extent, queued by osc_queue_sync_pages() */ oe_sync:1, - /** set if this extent has partial, sync pages. + /* set if this extent has partial, sync pages. * Extents with partial page(s) can't merge with others in RPC */ oe_no_merge:1, - oe_srvlock:1, - oe_memalloc:1, - /** an ACTIVE extent is going to be truncated, so when this extent + oe_srvlock:1, + oe_memalloc:1, + /* an ACTIVE extent is going to be truncated, so when this extent * is released, it will turn into TRUNC state instead of CACHE. */ - oe_trunc_pending:1, - /** this extent should be written asap and someone may wait for the + oe_trunc_pending:1, + /* this extent should be written asap and someone may wait for the * write to finish. This bit is usually set along with urgent if * the extent was CACHE state. * fsync_wait extent can't be merged because new extent region may * exceed fsync range. */ - oe_fsync_wait:1, - /** covering lock is being canceled */ - oe_hp:1, - /** this extent should be written back asap. set if one of pages is + oe_fsync_wait:1, + /* covering lock is being canceled */ + oe_hp:1, + /* this extent should be written back asap. set if one of pages is * called by page WB daemon, or sync write or reading requests. */ - oe_urgent:1; - /** how many grants allocated for this extent. + oe_urgent:1; + /* how many grants allocated for this extent. * Grant allocated for this extent. There is no grant allocated * for reading extents and sync write extents. */ - unsigned int oe_grants; - /** # of dirty pages in this extent */ - unsigned int oe_nr_pages; - /** list of pending oap pages. Pages in this list are NOT sorted. */ - struct list_head oe_pages; - /** Since an extent has to be written out in atomic, this is used to + unsigned int oe_grants; + /* # of dirty pages in this extent */ + unsigned int oe_nr_pages; + /* list of pending oap pages. Pages in this list are NOT sorted. */ + struct list_head oe_pages; + /* Since an extent has to be written out in atomic, this is used to * remember the next page need to be locked to write this extent out. * Not used right now. */ - struct osc_page *oe_next_page; - /** start and end index of this extent, include start and end + struct osc_page *oe_next_page; + /* start and end index of this extent, include start and end * themselves. Page offset here is the page index of osc_pages. * oe_start is used as keyword for red-black tree. */ - pgoff_t oe_start; - pgoff_t oe_end; - /** maximum ending index of this extent, this is limited by + pgoff_t oe_start; + pgoff_t oe_end; + /* maximum ending index of this extent, this is limited by * max_pages_per_rpc, lock extent and chunk size. */ - pgoff_t oe_max_end; - /** waitqueue - for those who want to be notified if this extent's + pgoff_t oe_max_end; + /* waitqueue - for those who want to be notified if this extent's * state has changed. */ wait_queue_head_t oe_waitq; - /** lock covering this extent */ + /* lock covering this extent */ struct ldlm_lock *oe_dlmlock; - /** terminator of this extent. Must be true if this extent is in IO. */ + /* terminator of this extent. Must be true if this extent is in IO. */ struct task_struct *oe_owner; - /** return value of writeback. If somebody is waiting for this extent, + /* return value of writeback. If somebody is waiting for this extent, * this value can be known by outside world. */ - int oe_rc; - /** max pages per rpc when this extent was created */ - unsigned int oe_mppr; + int oe_rc; + /* max pages per rpc when this extent was created */ + unsigned int oe_mppr; }; int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext, @@ -677,6 +678,6 @@ typedef int (*osc_page_gang_cbt)(const struct lu_env *, struct cl_io *, int osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io, struct osc_object *osc, pgoff_t start, pgoff_t end, osc_page_gang_cbt cb, void *cbdata); -/** @} osc */ +/* @} osc */ #endif /* OSC_CL_INTERNAL_H */ diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 55054d705a01..0de8a3ee826d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -43,54 +43,56 @@ extern struct ptlrpc_request_pool *osc_rq_pool; struct lu_env; enum async_flags { - ASYNC_READY = 0x1, /* ap_make_ready will not be called before this - * page is added to an rpc - */ - ASYNC_URGENT = 0x2, /* page must be put into an RPC before return */ - ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called - * to give the caller a chance to update - * or cancel the size of the io - */ + ASYNC_READY = 0x1, /* ap_make_ready will not be + * called before this page is + * added to an rpc + */ + ASYNC_URGENT = 0x2, /* page must be put into an RPC + * before return */ + ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be + * called to give the caller a + * chance to update or cancel + * the size of the io + */ ASYNC_HP = 0x10, }; struct osc_async_page { - int oap_magic; - unsigned short oap_cmd; - unsigned short oap_interrupted:1; + int oap_magic; + unsigned short oap_cmd; + unsigned short oap_interrupted:1; - struct list_head oap_pending_item; - struct list_head oap_rpc_item; + struct list_head oap_pending_item; + struct list_head oap_rpc_item; - u64 oap_obj_off; - unsigned int oap_page_off; - enum async_flags oap_async_flags; + u64 oap_obj_off; + unsigned int oap_page_off; + enum async_flags oap_async_flags; - struct brw_page oap_brw_page; + struct brw_page oap_brw_page; - struct ptlrpc_request *oap_request; - struct client_obd *oap_cli; - struct osc_object *oap_obj; + struct ptlrpc_request *oap_request; + struct client_obd *oap_cli; + struct osc_object *oap_obj; - spinlock_t oap_lock; + spinlock_t oap_lock; }; #define oap_page oap_brw_page.pg -#define oap_count oap_brw_page.count -#define oap_brw_flags oap_brw_page.flag +#define oap_count oap_brw_page.count +#define oap_brw_flags oap_brw_page.flag static inline struct osc_async_page *brw_page2oap(struct brw_page *pga) { - return (struct osc_async_page *)container_of(pga, struct osc_async_page, - oap_brw_page); + return container_of(pga, struct osc_async_page, oap_brw_page); } struct osc_cache_waiter { - struct list_head ocw_entry; - wait_queue_head_t ocw_waitq; - struct osc_async_page *ocw_oap; - int ocw_grant; - int ocw_rc; + struct list_head ocw_entry; + wait_queue_head_t ocw_waitq; + struct osc_async_page *ocw_oap; + int ocw_grant; + int ocw_rc; }; void osc_wake_cache_waiters(struct client_obd *cli); @@ -166,19 +168,19 @@ static inline char *cli_name(struct client_obd *cli) } struct osc_device { - struct cl_device od_cl; - struct obd_export *od_exp; + struct cl_device od_cl; + struct obd_export *od_exp; /* Write stats is actually protected by client_obd's lock. */ struct osc_stats { - u64 os_lockless_writes; /* by bytes */ - u64 os_lockless_reads; /* by bytes */ - u64 os_lockless_truncates; /* by times */ - } od_stats; + u64 os_lockless_writes; /* by bytes */ + u64 os_lockless_reads; /* by bytes */ + u64 os_lockless_truncates; /* by times */ + } od_stats; /* configuration item(s) */ - int od_contention_time; - int od_lockless_truncate; + int od_contention_time; + int od_lockless_truncate; }; static inline struct osc_device *obd2osc_dev(const struct obd_device *d) @@ -190,10 +192,10 @@ extern struct lu_kmem_descr osc_caches[]; extern struct kmem_cache *osc_quota_kmem; struct osc_quota_info { - /** linkage for quota hash table */ - struct rhash_head oqi_hash; - u32 oqi_id; - struct rcu_head rcu; + /* linkage for quota hash table */ + struct rhash_head oqi_hash; + u32 oqi_id; + struct rcu_head rcu; }; int osc_quota_setup(struct obd_device *obd); @@ -207,16 +209,16 @@ void osc_inc_unstable_pages(struct ptlrpc_request *req); void osc_dec_unstable_pages(struct ptlrpc_request *req); bool osc_over_unstable_soft_limit(struct client_obd *cli); -/** +/* * Bit flags for osc_dlm_lock_at_pageoff(). */ enum osc_dap_flags { - /** + /* * Just check if the desired lock exists, it won't hold reference * count on lock. */ OSC_DAP_FL_TEST_LOCK = BIT(0), - /** + /* * Return the lock even if it is being canceled. */ OSC_DAP_FL_CANCELING = BIT(1), @@ -228,9 +230,9 @@ struct ldlm_lock *osc_dlmlock_at_pgoff(const struct lu_env *env, int osc_object_invalidate(const struct lu_env *env, struct osc_object *osc); -/** osc shrink list to link all osc client obd */ +/* osc shrink list to link all osc client obd */ extern struct list_head osc_shrink_list; -/** spin lock to protect osc_shrink_list */ +/* spin lock to protect osc_shrink_list */ extern spinlock_t osc_shrink_lock; unsigned long osc_cache_shrink_count(struct shrinker *sk, struct shrink_control *sc);