From mboxrd@z Thu Jan 1 00:00:00 1970 From: yushang Subject: Re: a question about clone_mnt in namespace.c Date: Sun, 1 Jul 2012 10:03:12 +0800 Message-ID: References: <20120622092924.GC14083@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Cc: linux-fsdevel@vger.kernel.org To: Al Viro Return-path: Received: from mail-gh0-f174.google.com ([209.85.160.174]:48012 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751666Ab2GACDM (ORCPT ); Sat, 30 Jun 2012 22:03:12 -0400 Received: by ghrr11 with SMTP id r11so3569348ghr.19 for ; Sat, 30 Jun 2012 19:03:12 -0700 (PDT) In-Reply-To: <20120622092924.GC14083@ZenIV.linux.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Thanks for reply. I think mnt_slave and mnt_master are integrity parts of master/slave semantics and put the 2 lines together will make the logic clearer. Many thanks. 2012/6/22 Al Viro : > On Wed, Jun 20, 2012 at 10:54:00AM +0800, yushang wrote: >> Hi dear all, >> I have a question about the mnt_master logic in clone_mnt , look at >> following lines: >> ... >> } else if (!(flag & CL_PRIVATE)) { >> if ((flag & CL_MAKE_SHARED) || IS_MNT_SHARED(old)) >> list_add(&mnt->mnt_share, &old->mnt_share); >> if (IS_MNT_SLAVE(old)) >> list_add(&mnt->mnt_slave, &old->mnt_slave); >> mnt->mnt_master = old->mnt_master; >> } >> ... >> I think the following lines are equivalent, right ? or I've missed >> something ? many thanks! >> ... >> } else if (!(flag & CL_PRIVATE)) { >> if ((flag & CL_MAKE_SHARED) || IS_MNT_SHARED(old)) >> list_add(&mnt->mnt_share, &old->mnt_share); >> if (IS_MNT_SLAVE(old)) { >> list_add(&mnt->mnt_slave, &old->mnt_slave); >> mnt->mnt_master = old->mnt_master; >> } >> } > > Yes; we are guaranteed that mnt->master is NULL after alloc_vfsmnt(), > so that would be an equivalent transformation. Matter of taste, > mostly - performance win is negligible and IMO your variant is > slightly less explicit.