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 B34E5C2BA2B for ; Fri, 10 Apr 2020 06:04:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7D50A2051A for ; Fri, 10 Apr 2020 06:04:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725818AbgDJGE0 (ORCPT ); Fri, 10 Apr 2020 02:04:26 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:59822 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbgDJGE0 (ORCPT ); Fri, 10 Apr 2020 02:04:26 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jMmm6-00FnMr-DK; Fri, 10 Apr 2020 06:04:22 +0000 Date: Fri, 10 Apr 2020 07:04:22 +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: <20200410060422.GJ23230@ZenIV.linux.org.uk> References: <20200410050522.GI28467@miu.piliscsaba.redhat.com> <20200410051457.GI23230@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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:23:47AM +0200, Miklos Szeredi wrote: > > 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); > > If you prefer that, yes. Functionally it's equivalent. Sure, it's just that I suspect that result will be somewhat more readable that way. Incidentally, there might be another benefit - both &p->ns->list.next and &p->mnt.mnt_list.next are not going to change. So calculation of prev can be lifter out of lock_ns_list() and _that_ promises something more tasty - all callers of mnt_skip_cursors() are immediately surrounded by lock_ns_list()/unlock_ns_list() and those can be moved inside the damn thing.