From patchwork Tue Apr 14 06:17:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 11486827 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 981336CA for ; Tue, 14 Apr 2020 06:18:26 +0000 (UTC) Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 35225206E9 for ; Tue, 14 Apr 2020 06:18:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 35225206E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=ocfs2-devel-bounces@oss.oracle.com Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03E6CZvF173079; Tue, 14 Apr 2020 06:18:07 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 30b5ar2d0n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Apr 2020 06:18:07 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03E6GwV5192849; Tue, 14 Apr 2020 06:18:07 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userp3020.oracle.com with ESMTP id 30bqm0r2a4-1 (version=TLSv1 cipher=AES256-SHA bits=256 verify=NO); Tue, 14 Apr 2020 06:18:07 +0000 Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1jOEtZ-0008Gt-VF; Mon, 13 Apr 2020 23:18:05 -0700 Received: from userp3020.oracle.com ([156.151.31.79]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1jOEt1-0008Et-CJ for ocfs2-devel@oss.oracle.com; Mon, 13 Apr 2020 23:17:31 -0700 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03E6GusQ192635 for ; Tue, 14 Apr 2020 06:17:31 GMT Received: from userp2030.oracle.com (userp2030.oracle.com [156.151.31.89]) by userp3020.oracle.com with ESMTP id 30bqm0r10m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 14 Apr 2020 06:17:29 +0000 Received: from pps.filterd (userp2030.oracle.com [127.0.0.1]) by userp2030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03E64rKS011453 for ; Tue, 14 Apr 2020 06:17:29 GMT Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) by userp2030.oracle.com with ESMTP id 30d6wj0prc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Apr 2020 06:17:28 +0000 Received: from vvs-ws.sw.ru ([172.16.24.21]) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jOEsX-0000pp-Im; Tue, 14 Apr 2020 09:17:01 +0300 From: Vasily Averin To: ocfs2-devel@oss.oracle.com References: <085dc97b-de01-1d95-799d-dc795eec7818@virtuozzo.com> Message-ID: Date: Tue, 14 Apr 2020 09:17:01 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 In-Reply-To: <085dc97b-de01-1d95-799d-dc795eec7818@virtuozzo.com> Content-Language: en-US MIME-Version: 1.0 X-PDR: PASS X-Source-IP: 185.231.240.75 X-ServerName: relay.sw.ru X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 include:spf.protection.outlook.com ip4:89.145.166.222 ip4:185.231.240.0/23 include:aspmx.pardot.com ~all X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9590 signatures=668686 X-Proofpoint-Spam-Details: rule=tap_spam_policies_notspam policy=tap_spam_policies score=0 impostorscore=0 bulkscore=0 adultscore=0 malwarescore=0 priorityscore=143 clxscore=139 spamscore=0 suspectscore=2 lowpriorityscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140037 X-Spam: Clean X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=2 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140050 Subject: [Ocfs2-devel] [PATCH v3 1/4] ocfs2: debug_lockres_ops should properly handle position index X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9590 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=2 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140050 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9590 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 phishscore=0 spamscore=0 mlxlogscore=999 suspectscore=2 adultscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140049 Currently debug_lockres_ops ignores position index argument, and it leads to incorrect output in case of read with offset. Link: https://oss.oracle.com/pipermail/ocfs2-devel/2020-March/014822.html By design .start function should skip first *pos elements, and .next function must update position index unconditionally. debug_lockres_ops was reworked to satisfy these requirements: - .start and .next functions iterates on dlm->tracking_list by using seq_list_* primitives - .show generates output related to selected dlm_lock_resource - .stop function is used to release taken dlm_lock_resource Cc: stable@vger.kernel.org Fixes: 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code ...") Link: https://urldefense.com/v3/__https://bugzilla.kernel.org/show_bug.cgi?id=206283__;!!GqivPVa7Brio!KOf5kpSuieredwp9lEzV0BQklJAQy4ix8PUtCrqkLdv2TsSnX570XW7JT9gBvV6thJkj2g$ Signed-off-by: Vasily Averin --- fs/ocfs2/dlm/dlmdebug.c | 78 ++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c index 4b8b41d23e91..1887affbbf2c 100644 --- a/fs/ocfs2/dlm/dlmdebug.c +++ b/fs/ocfs2/dlm/dlmdebug.c @@ -542,63 +542,63 @@ static void *lockres_seq_start(struct seq_file *m, loff_t *pos) { struct debug_lockres *dl = m->private; struct dlm_ctxt *dlm = dl->dl_ctxt; - struct dlm_lock_resource *oldres = dl->dl_res; struct dlm_lock_resource *res = NULL; - struct list_head *track_list; + struct list_head *lh; spin_lock(&dlm->track_lock); - if (oldres) - track_list = &oldres->tracking; - else { - track_list = &dlm->tracking_list; - if (list_empty(track_list)) { - dl = NULL; - spin_unlock(&dlm->track_lock); - goto bail; - } - } - - list_for_each_entry(res, track_list, tracking) { - if (&res->tracking == &dlm->tracking_list) - res = NULL; - else - dlm_lockres_get(res); - break; + lh = seq_list_start(&dlm->tracking_list, *pos); + if (lh) { + res = list_entry(lh, struct dlm_lock_resource, tracking); + dlm_lockres_get(res); } + dl->dl_res = res; spin_unlock(&dlm->track_lock); + /* passed to seq_show */ + return res ? dl : NULL; +} - if (oldres) - dlm_lockres_put(oldres); +static void *lockres_seq_next(struct seq_file *m, void *v, loff_t *pos) +{ + struct debug_lockres *dl = (struct debug_lockres *)v; + struct dlm_ctxt *dlm = dl->dl_ctxt; + struct dlm_lock_resource *oldres = dl->dl_res; + struct dlm_lock_resource *res = NULL; + struct list_head *lh; + spin_lock(&dlm->track_lock); + lh = seq_list_next(&oldres->tracking, &dlm->tracking_list, pos); + if (lh) { + res = list_entry(lh, struct dlm_lock_resource, tracking); + dlm_lockres_get(res); + } dl->dl_res = res; - - if (res) { - spin_lock(&res->spinlock); - dump_lockres(res, dl->dl_buf, dl->dl_len - 1); - spin_unlock(&res->spinlock); - } else - dl = NULL; - -bail: - /* passed to seq_show */ - return dl; + spin_unlock(&dlm->track_lock); + dlm_lockres_put(oldres); + return res ? dl : NULL; } static void lockres_seq_stop(struct seq_file *m, void *v) { -} + struct debug_lockres *dl = (struct debug_lockres *)v; + struct dlm_lock_resource *res = dl->dl_res; -static void *lockres_seq_next(struct seq_file *m, void *v, loff_t *pos) -{ - return NULL; + if (res) { + dlm_lockres_put(res); + dl->dl_res = NULL; + } } -static int lockres_seq_show(struct seq_file *s, void *v) +static int lockres_seq_show(struct seq_file *m, void *v) { struct debug_lockres *dl = (struct debug_lockres *)v; + struct dlm_lock_resource *res = dl->dl_res; - seq_printf(s, "%s", dl->dl_buf); - + if (res) { + spin_lock(&res->spinlock); + dump_lockres(res, dl->dl_buf, dl->dl_len - 1); + spin_unlock(&res->spinlock); + seq_printf(m, "%s", dl->dl_buf); + } return 0; }