Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp550615ybr; Fri, 22 May 2020 13:00:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEmyIZ1v47E59I14INf6nCo+zl1R7TdI8ftTEiNv1LhIyKVZ0rHWWnTVpihEEgqLhvgF9C X-Received: by 2002:a05:6402:c95:: with SMTP id cm21mr4452964edb.81.1590177619517; Fri, 22 May 2020 13:00:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590177619; cv=none; d=google.com; s=arc-20160816; b=YUiUOYEMYkWDoHzzdKIgPUHE+loy1Rwi8eLX0J6C6fybH1RdE2KtRI5sF3NnLYPYeI rOmx09gQAu6nRl1J100g9r1PfA70mqKmsPPuQ2jiag1wWmq7XjafxQFxtUnrMLbt3KsS tQ8oUBrtSRIF9vMiSVmx7NroUCGMvyUPAPEjTlCUboEKKkcqCA93Ys4101+xazCGL3px FpguKKSzZjuw1iovHkQBZcliCyk76VDkDxac+xl1/ibCj8uwazvSaUiloSUQPEXfBLKg glZOCFeS6wmbzH2M5+fc3sDa8N8VDq09MHyN5IV9t32yef3MaXZvTYOeuqYQQKPUeieN AqdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=5+ihe6XVwVcsXETlXMle7NJ6+IUktyDCi3cwYBQNzX4=; b=QrhbOVsJFepwBZ5f/vHgGbA4BPU+kpeX4agXvDEAtVMaZroQ61ueUsPbabTL53Vf4v 1amK9ut/ECjsDYCMT29PDSHezrwBCZloDBEzzCyzkRQ+wFa9zMigjv7eVuO8hQ1eFCX7 sK23Yb+baO0ER7eWEohBzdn4KGU4P1OTiqmIb+FjkGYkdI8cigIWfK0Wc5bi5/fOir5/ btWvHewhSS4K4+97DQRkTkIdVIiiEVM5xwnQ9Kr/c1aZCBsq+s71KD5VEwOGGdy2MXX5 NxEIbbghrjg8WVNbNzvML24is8QlZydRz9khxbKDYb6HeytAlxlpbUemjQiihx08Ttxg sI+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z23si5418415ejr.394.2020.05.22.12.59.56; Fri, 22 May 2020 13:00:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730994AbgEVT4d (ORCPT + 99 others); Fri, 22 May 2020 15:56:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730893AbgEVT4d (ORCPT ); Fri, 22 May 2020 15:56:33 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5AC1C061A0E; Fri, 22 May 2020 12:56:32 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.93 #3 (Red Hat Linux)) id 1jcDmM-00Dfk3-I0; Fri, 22 May 2020 19:56:26 +0000 Date: Fri, 22 May 2020 20:56:26 +0100 From: Al Viro To: Miklos Szeredi Cc: Amir Goldstein , overlayfs , linux-fsdevel , lkml Subject: Re: [PATCH] ovl: make private mounts longterm Message-ID: <20200522195626.GV23230@ZenIV.linux.org.uk> References: <20200522085723.29007-1-mszeredi@redhat.com> <20200522160815.GT23230@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 22, 2020 at 08:53:49PM +0200, Miklos Szeredi wrote: > On Fri, May 22, 2020 at 7:02 PM Amir Goldstein wrote: > > > > > > > - mntput(ofs->upper_mnt); > > > > > - for (i = 1; i < ofs->numlayer; i++) { > > > > > - iput(ofs->layers[i].trap); > > > > > - mntput(ofs->layers[i].mnt); > > > > > + > > > > > + if (!ofs->layers) { > > > > > + /* Deal with partial setup */ > > > > > + kern_unmount(ofs->upper_mnt); > > > > > + } else { > > > > > + /* Hack! Reuse ofs->layers as a mounts array */ > > > > > + struct vfsmount **mounts = (struct vfsmount **) ofs->layers; > > > > > + > > > > > + for (i = 0; i < ofs->numlayer; i++) { > > > > > + iput(ofs->layers[i].trap); > > > > > + mounts[i] = ofs->layers[i].mnt; > > > > > + } > > > > > + kern_unmount_many(mounts, ofs->numlayer); > > > > > + kfree(ofs->layers); > > > > > > > > That's _way_ too subtle. AFAICS, you rely upon ->upper_mnt == ->layers[0].mnt, > > > > ->layers[0].trap == NULL, without even mentioning that. And the hack you do > > > > mention... Yecchhh... How many layers are possible, again? > > > > > > 500, mounts array would fit inside a page and a page can be allocated > > > with __GFP_NOFAIL. But why bother? It's not all that bad, is it? > > > > FWIW, it seems fine to me. > > We can transfer the reference from upperdir_trap to layers[0].trap > > when initializing layers[0] for the sake of clarity. > > Right, we should just get rid of ofs->upper_mnt and ofs->upperdir_trap > and use ofs->layers[0] to store those. For that you'd need to allocate ->layers before you get to ovl_get_upper(), though. I'm not saying it's a bad idea - doing plain memory allocations before anything else tends to make failure exits cleaner; it's just that it'll take some massage. Basically, do ovl_split_lowerdirs() early, then allocate everything you need, then do lookups, etc., filling that stuff. Regarding this series - the points regarding the name choice and the need to document the calling conventions change still remain.