From patchwork Tue Apr 14 06:17:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 11486829 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 81C2E6CA for ; Tue, 14 Apr 2020 06:18:28 +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 5F476206E9 for ; Tue, 14 Apr 2020 06:18:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F476206E9 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 03E6CX1Z172972; Tue, 14 Apr 2020 06:18:19 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 30b5ar2d1r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Apr 2020 06:18:19 +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 03E6Gush192635; Tue, 14 Apr 2020 06:18:19 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userp3020.oracle.com with ESMTP id 30bqm0r2kf-1 (version=TLSv1 cipher=AES256-SHA bits=256 verify=NO); Tue, 14 Apr 2020 06:18:19 +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 1jOEtm-0008Ih-5t; Mon, 13 Apr 2020 23:18:18 -0700 Received: from userp3030.oracle.com ([156.151.31.80]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1jOEtE-0008Fi-8k for ocfs2-devel@oss.oracle.com; Mon, 13 Apr 2020 23:17:44 -0700 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03E6HinE165539 for ; Tue, 14 Apr 2020 06:17:44 GMT Received: from userp2040.oracle.com (userp2040.oracle.com [156.151.31.90]) by userp3030.oracle.com with ESMTP id 30bqcgmam2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 14 Apr 2020 06:17:43 +0000 Received: from pps.filterd (userp2040.oracle.com [127.0.0.1]) by userp2040.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03E64S8J045420 for ; Tue, 14 Apr 2020 06:17:32 GMT Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) by userp2040.oracle.com with ESMTP id 30d6x0rrtx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Apr 2020 06:17:32 +0000 Received: from vvs-ws.sw.ru ([172.16.24.21]) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jOEsq-0000qB-41; Tue, 14 Apr 2020 09:17:20 +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:19 +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 lowpriorityscore=0 clxscore=140 impostorscore=0 bulkscore=0 phishscore=0 priorityscore=151 malwarescore=0 spamscore=0 mlxlogscore=777 mlxscore=0 adultscore=0 suspectscore=2 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 suspectscore=2 mlxlogscore=999 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140050 Subject: [Ocfs2-devel] [PATCH v3 3/4] ocfs2: nst_seq_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=1011 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 nst_seq_ops ignores position index argument, and it leads to incorrect output in case of read with offset. By design .start function should skip first *pos elements, and .next function must update position index unconditionally. 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!McCQFYlmRnNmoAtY2bRAeiRzKSgC0c8B5r-Oy1meJpaRZaM5TbD5lECuzD96ZyERbIiA3Q$ Signed-off-by: Vasily Averin --- fs/ocfs2/cluster/netdebug.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/ocfs2/cluster/netdebug.c b/fs/ocfs2/cluster/netdebug.c index 667a5c5e1f66..8ca8a407781b 100644 --- a/fs/ocfs2/cluster/netdebug.c +++ b/fs/ocfs2/cluster/netdebug.c @@ -60,7 +60,8 @@ void o2net_debug_del_nst(struct o2net_send_tracking *nst) } static struct o2net_send_tracking - *next_nst(struct o2net_send_tracking *nst_start) + *next_nst(struct o2net_send_tracking *nst_start, + loff_t pos) { struct o2net_send_tracking *nst, *ret = NULL; @@ -73,7 +74,7 @@ static struct o2net_send_tracking break; /* use st_task to detect real nsts in the list */ - if (nst->st_task != NULL) { + if ((nst->st_task != NULL) && (pos-- == 0)) { ret = nst; break; } @@ -87,7 +88,7 @@ static void *nst_seq_start(struct seq_file *seq, loff_t *pos) struct o2net_send_tracking *nst, *dummy_nst = seq->private; spin_lock(&o2net_debug_lock); - nst = next_nst(dummy_nst); + nst = next_nst(dummy_nst, *pos); spin_unlock(&o2net_debug_lock); return nst; @@ -97,8 +98,9 @@ static void *nst_seq_next(struct seq_file *seq, void *v, loff_t *pos) { struct o2net_send_tracking *nst, *dummy_nst = seq->private; + (*pos)++; spin_lock(&o2net_debug_lock); - nst = next_nst(dummy_nst); + nst = next_nst(dummy_nst, 0); list_del_init(&dummy_nst->st_net_debug_item); if (nst) list_add(&dummy_nst->st_net_debug_item, @@ -115,7 +117,7 @@ static int nst_seq_show(struct seq_file *seq, void *v) s64 sock, send, status; spin_lock(&o2net_debug_lock); - nst = next_nst(dummy_nst); + nst = next_nst(dummy_nst, 0); if (!nst) goto out;