From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3120DC2BA2B for ; Fri, 10 Apr 2020 05:15:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F3B8F207FF for ; Fri, 10 Apr 2020 05:15:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725816AbgDJFPA (ORCPT ); Fri, 10 Apr 2020 01:15:00 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:59386 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725710AbgDJFPA (ORCPT ); Fri, 10 Apr 2020 01:15:00 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jMm0H-00Flag-Ro; Fri, 10 Apr 2020 05:14:57 +0000 Date: Fri, 10 Apr 2020 06:14:57 +0100 From: Al Viro To: Miklos Szeredi Cc: Karel Zak , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v4] proc/mounts: add cursor Message-ID: <20200410051457.GI23230@ZenIV.linux.org.uk> References: <20200410050522.GI28467@miu.piliscsaba.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200410050522.GI28467@miu.piliscsaba.redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Fri, Apr 10, 2020 at 07:05:22AM +0200, Miklos Szeredi wrote: > + /* read after we'd reached the end? */ > + if (*pos && list_empty(&mnt->mnt_list)) > + return NULL; > + > + lock_ns_list(p->ns); > + if (!*pos) > + mnt = list_first_entry(&p->ns->list, typeof(*mnt), mnt_list); > + mnt = mnt_skip_cursors(p->ns, mnt); > + unlock_ns_list(p->ns); > > - p->cached_event = p->ns->event; > - p->cached_mount = seq_list_start(&p->ns->list, *pos); > - p->cached_index = *pos; > - return p->cached_mount; > + return mnt; > } Hmm... I wonder if it would be better to do something like if (!*pos) prev = &p->ns->list.next; else prev = &p->mnt.mnt_list.next; mnt = mnt_skip_cursors(p->ns, prev); > static void *m_next(struct seq_file *m, void *v, loff_t *pos) > { > struct proc_mounts *p = m->private; > + struct mount *mnt = v; > + > + lock_ns_list(p->ns); > + mnt = mnt_skip_cursors(p->ns, list_next_entry(mnt, mnt_list)); ... and mnt = mnt_skip_cursors(p->ns, &mnt->mnt_list.next);