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 D53F0C2BA19 for ; Fri, 10 Apr 2020 01:11:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9CE7E2074F for ; Fri, 10 Apr 2020 01:11:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726477AbgDJBLW (ORCPT ); Thu, 9 Apr 2020 21:11:22 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:56798 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbgDJBLW (ORCPT ); Thu, 9 Apr 2020 21:11:22 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jMiCV-00FcYm-1b; Fri, 10 Apr 2020 01:11:19 +0000 Date: Fri, 10 Apr 2020 02:11:19 +0100 From: Al Viro To: Miklos Szeredi Cc: Karel Zak , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v3] proc/mounts: add cursor Message-ID: <20200410011119.GH23230@ZenIV.linux.org.uk> References: <20200409212214.GG28467@miu.piliscsaba.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200409212214.GG28467@miu.piliscsaba.redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Thu, Apr 09, 2020 at 11:22:14PM +0200, Miklos Szeredi wrote: > @@ -1249,42 +1277,50 @@ struct vfsmount *mnt_clone_internal(cons > static void *m_start(struct seq_file *m, loff_t *pos) > { > struct proc_mounts *p = m->private; > + struct mount *mnt = NULL; > > down_read(&namespace_sem); > - if (p->cached_event == p->ns->event) { > - void *v = p->cached_mount; > - if (*pos == p->cached_index) > - return v; > - if (*pos == p->cached_index + 1) { > - v = seq_list_next(v, &p->ns->list, &p->cached_index); > - return p->cached_mount = v; > - } > - } > + lock_ns_list(p->ns); > + if (!*pos) > + list_move(&p->cursor.mnt_list, &p->ns->list); > + if (!list_empty(&p->cursor.mnt_list)) > + mnt = mnt_skip_cursors(p->ns, &p->cursor); > + unlock_ns_list(p->ns); Huh? What's that if (!list_empty()) about? The case where we have reached the end of list, then did a read() with an lseek() in between? If so, then this is out of place under your spinlock; "is on the list" state changes only synchronously (seq_file ->lock serializes all of that). *If* this is what you've meant, I'd suggest /* read after we'd reached the end? */ if (*pos && list_empty(...)) return NULL; lock_ns_list(p->ns); if (!*pos) list_move(...); /* rewind on lseek or initial read */ mnt = mnt_skip_cursors(...); unlock_ns_list(p->ns); Or am I misreading your intent there? Confused...