Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp511034ybr; Fri, 22 May 2020 11:56:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3kpf7iyERR6lMuSSmuHvxrBgOfVPM2kEyuvu9rbEg8QrFrMczxVpgemZ1ehQhcgCoE25I X-Received: by 2002:a17:906:b348:: with SMTP id cd8mr9284466ejb.139.1590173759746; Fri, 22 May 2020 11:55:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590173759; cv=none; d=google.com; s=arc-20160816; b=ENTv7t6dnzMHMj0T3omdE77wFvVrlobRtVkPDeL2N9icuPjBMzu0xTo/4Nk9/na5zA bNPaax7BkiA8jCDa8SjbE8o7oKpzwwxx361DwHZt9eWjEZm+AgEOxH98Umc0/ZmOblcs kHZT2V+kSFBloAnZe2zFfhhT2zVXnpxZ+ksr1NNPcooxIBI9s2qck4vCR7MmMhuZ4HsQ 6hkjCv299hfnLsplVbEKpNkO/VH6/2wsCSieNR8K1zosYiMgC5ANTrCQzbPKwGIeOk6S pvNBnUZ2rDHYZGzPcciEnRTPMjVRVfwPlukK23x9cT3bIuLicKw5OFsqzF+okIu9CLFv 4Cig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=E/NY7atph5yZUS2SuBQhFRnCbvYDVMYgXeB+elMZM6I=; b=jqn1pbc7/eBpiprWNUBsmwDAjadbzjZlBF6AlqfslXpaoGYyDHfsEdhcP+dn6+o6r4 PnyUNMg3UHwo4jtOYrpQsLUgMAg6xoFvKNY/tNzJbSUi3SdWWauCB9VIFolnfUqXimIQ P98dPTHyHs6uhGEn1z3F7dHq0oJr60FIAsx4aDnhVAmmkp1Wf2K5nVZ0bNDTFchWMVXA M9sp2G0rD7LATYkLhAazEbfbK0QOrBLVDdfIwrbq2c6gcPwfpwrl5nP7prxX44gYldSt k8EKxOb61j58nB0Um1XUitoBJc+duLqq5ko9Rmxbyl/TbCN/U1ontsEG32o2MwtKl4QN YIpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=amtXwRdY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp4si6515149ejc.258.2020.05.22.11.55.36; Fri, 22 May 2020 11:55:59 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=amtXwRdY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730840AbgEVSyF (ORCPT + 99 others); Fri, 22 May 2020 14:54:05 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:43446 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730849AbgEVSyE (ORCPT ); Fri, 22 May 2020 14:54:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590173643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E/NY7atph5yZUS2SuBQhFRnCbvYDVMYgXeB+elMZM6I=; b=amtXwRdYpBAynydkA/N8OtKGpzTze0aeLqO8H8ZvLn0AOhyAxqi2Q7w2Rp6mVpDypywL2d +G/Hpzj8ek5EMUE47fUhR6Jm3HKN8rYHVrOgJIj82B66mLTcxxG6pVom21k6D59dfe9uTA 6HUg0F1WqFVKn7AP/kV3Mnb6BkFTnHo= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-56-opvqkVjZPhWoXRI7jSp0cg-1; Fri, 22 May 2020 14:54:01 -0400 X-MC-Unique: opvqkVjZPhWoXRI7jSp0cg-1 Received: by mail-qt1-f198.google.com with SMTP id n33so12729851qtd.10 for ; Fri, 22 May 2020 11:54:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=E/NY7atph5yZUS2SuBQhFRnCbvYDVMYgXeB+elMZM6I=; b=Y+L2kB19de7mzchLF/Mi7BIVennb3vgNFKGawpdIh1Ncqcky31QhZf/4PrDsKaJT7/ e/jZpN4MjORtrwRpXG4QRIqx54rl0CA/mPrmUR1/HN2nFOnu+UJTlkL4BAyXbqoOsEfh M2/Lt2LPVKuQMBDNUMkr6deF+RLDEGmCV6YSYrrrfxRARwUu1/m0uffOkXIk91hQUP7l NFxgRhExzkdts2A15Vcyn5veTpm6TXZtgEZUxC2ZpQerxQrQMkVESurhkfBis9L6Zui6 n9mrb2sO88jK7YDuZjBisb4S0DbSxAdL4NP5aCFO6FnC+ECqI6fGWC2zcNNOwQikOarN GCdQ== X-Gm-Message-State: AOAM531pLbmAyaWad/6i4tUuQkPVMgGfPeqVlLKduAlC2j/E94p2ovhj fIrd8pHeywmeBJoWa8scU5Fo/fX3jXrh9PMZeEXfiispqqFzuTbOPg6tzcp7Iaxm7rYvRMgZ4QR Rr3l0kcx5ohQ9EfNC07HVA8Z7nzu65qru0oCGxCm7 X-Received: by 2002:ac8:6a09:: with SMTP id t9mr17251949qtr.7.1590173641101; Fri, 22 May 2020 11:54:01 -0700 (PDT) X-Received: by 2002:ac8:6a09:: with SMTP id t9mr17251936qtr.7.1590173640781; Fri, 22 May 2020 11:54:00 -0700 (PDT) MIME-Version: 1.0 References: <20200522085723.29007-1-mszeredi@redhat.com> <20200522160815.GT23230@ZenIV.linux.org.uk> In-Reply-To: From: Miklos Szeredi Date: Fri, 22 May 2020 20:53:49 +0200 Message-ID: Subject: Re: [PATCH] ovl: make private mounts longterm To: Amir Goldstein Cc: Al Viro , overlayfs , linux-fsdevel , lkml Content-Type: text/plain; charset="UTF-8" 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 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. Thanks, Miklos