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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD8F6C54EE9 for ; Thu, 8 Sep 2022 15:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231579AbiIHPhM (ORCPT ); Thu, 8 Sep 2022 11:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230309AbiIHPgr (ORCPT ); Thu, 8 Sep 2022 11:36:47 -0400 Received: from mail-vs1-xe34.google.com (mail-vs1-xe34.google.com [IPv6:2607:f8b0:4864:20::e34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B6B5AD99B for ; Thu, 8 Sep 2022 08:36:40 -0700 (PDT) Received: by mail-vs1-xe34.google.com with SMTP id k2so18685455vsk.8 for ; Thu, 08 Sep 2022 08:36:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=9w8Y/xC/jsEceGZBl1FXnaUxTQL5UGAsHdluHjal+TU=; b=HarqLkmJxIryK3EITmJE7EsDhYVNgKed9z1wyayvGtYuu6gWLmWjmTT4q7i04gSOiN XHBgIr/NCD7mBPQGeYil75pMdfQvQDxke+14jMeZXW0UM0plQmmzTgmF2g067+jw46zm pdLw0eYe7NpcLFPOzp6N9Ke/g3v8nzHTAyy3BRMfFJvelu/ZMQ5UwUQAuxxdhMqdZjLw cO0bbK13ErZBH0FfhcpIOH4V9tjfrueECg5xV1+qmQHkwiGisXrDEEizyRqI02iCkhCP ZZrRZK5uz1i3B3TtPfzPsvi54enXoMI2/ezn2H2SkXj5rFzV3GvSFir8LLQS/E/aNShr dzSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=9w8Y/xC/jsEceGZBl1FXnaUxTQL5UGAsHdluHjal+TU=; b=HQ02Dd7bGYwM878nL5Snmm8gmnxSpWZDQTCx5xaK2O+Kkbo3sSOknHjjGFlP2dyNCq 0JkZwEJfJ5qN3DW6LoZGbNQxwMKNZwcRjD8SuJDQd1W/lVRowNcCDQobspWYjdAKsrQw rzxdSFoGFP2F3dpPKgtwRk9ajHB86heHgSWyv2IkYjolQbsQwloxmZvIb2+H9yf7R0fT WD8MkqqRd6V3pYLkWCO2ZU5xO4KtfMpCw804p8E6lXWdGgU941g6XYCMWH1dkBWJkFyd srRomeSoGu2e+UcEyI8+NTZeJWHhvAzlPl55qRi98jarpfy1kuzUjhqrsaNrNQPq7tyT gasw== X-Gm-Message-State: ACgBeo2oCXGk+bPISYIKWjAPJTqVUQwOLJDiOZGlXBFHKKskxa5jPq4T ZDHfR8X+PGmbcg5FfDt7WQWqqJLFi6DWIs03uwevp64j X-Google-Smtp-Source: AA6agR52Ta2njkVfGJ3blOKTKdTXGAsPCGqVA5PqM0uJ9TLFxT0o4elfWzvVA8WEWNHJL6ZZT6OczR3l6Xuj6iyb+mQ= X-Received: by 2002:a67:a649:0:b0:390:88c5:6a91 with SMTP id r9-20020a67a649000000b0039088c56a91mr3485586vsh.3.1662651399391; Thu, 08 Sep 2022 08:36:39 -0700 (PDT) MIME-Version: 1.0 References: <20210125153057.3623715-1-balsini@android.com> <20210125153057.3623715-4-balsini@android.com> In-Reply-To: From: Amir Goldstein Date: Thu, 8 Sep 2022 18:36:27 +0300 Message-ID: Subject: Re: [PATCH RESEND V12 3/8] fuse: Definitions and ioctl for passthrough To: Alessio Balsini , Miklos Szeredi Cc: Peng Tao , Akilesh Kailash , Antonio SJ Musumeci , David Anderson , Giuseppe Scrivano , Jann Horn , Jens Axboe , Martijn Coenen , Palmer Dabbelt , Paul Lawrence , Stefano Duo , Zimuzo Ezeozue , wuyan , fuse-devel , kernel-team , "linux-fsdevel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Hi Alessio and Miklos, Some time has passed.. and I was thinking of picking up these patches. On Mon, Mar 1, 2021 at 7:05 PM Alessio Balsini wrote: > > On Fri, Feb 19, 2021 at 09:40:21AM +0100, Miklos Szeredi wrote: > > On Fri, Feb 19, 2021 at 8:05 AM Peng Tao wrote: > > > > > > On Wed, Feb 17, 2021 at 9:41 PM Miklos Szeredi wrote: > > > > > > What I think would be useful is to have an explicit > > > > FUSE_DEV_IOC_PASSTHROUGH_CLOSE ioctl, that would need to be called > > > > once the fuse server no longer needs this ID. If this turns out to > > > > be a performance problem, we could still add the auto-close behavior > > > > with an explicit FOPEN_PASSTHROUGH_AUTOCLOSE flag later. > > > Hi Miklos, > > > > > > W/o auto closing, what happens if user space daemon forgets to call > > > FUSE_DEV_IOC_PASSTHROUGH_CLOSE? Do we keep the ID alive somewhere? > > > > Kernel would keep the ID open until explicit close or fuse connection > > is released. > > > > There should be some limit on the max open files referenced through > > ID's, though. E.g. inherit RLIMIT_NOFILE from mounting task. > > > > Thanks, > > Miklos > > I like the idea of FUSE_DEV_IOC_PASSTHROUGH_CLOSE to revoke the > passthrough access, that is something I was already working on. What I > had in mind was simply to break that 1:1 connection between fuse_file > and lower filp setting a specific fuse_file::passthrough::filp to NULL, > but this is slightly different from what you mentioned. > I don't like the idea of switching between passthrough and server mid-life of an open file. There are consequences related to syncing the attribute cache of the kernel and the server that I don't even want to think about. > AFAIU you are suggesting to allocate one ID for each lower fs file > opened with passthrough within a connection, and maybe using idr_find at > every read/write/mmap operation to check if passthrough is enabled on > that file. Something similar to fuse2_map_get(). > This way the fuse server can pass the same ID to one or more > fuse_file(s). > FUSE_DEV_IOC_PASSTHROUGH_CLOSE would idr_remove the ID, so idr_find > would fail, preventing the use of passthrough on that ID. CMIIW. > I don't think that FUSE_DEV_IOC_PASSTHROUGH_CLOSE should remove the ID. We can use a refcount for the mapping and FUSE_DEV_IOC_PASSTHROUGH_CLOSE just drops the initial server's refcount. Implementing revoke for an existing mapping is something completely different. It can be done, not even so hard, but I don't think it should be part of this series and in any case revoke will not remove the ID. > After FUSE_DEV_IOC_PASSTHROUGH_CLOSE(ID) it may happen that if some > fuse_file(s) storing that ID are still open and the same ID is reclaimed > in a new idr_alloc, this would lead to mismatching lower fs filp being > used by our fuse_file(s). So also the ID stored in the fuse_file(s) > must be invalidated to prevent future uses of deallocated IDs. Obtaining a refcount on FOPEN_PASSTHROUGH will solve that. > > Would it make sense to have a list of fuse_files using the same ID, that > must be traversed at FUSE_DEV_IOC_PASSTHROUGH_CLOSE time? > Negative values (maybe -ENOENT) might be used to mark IDs as invalid, > and tested before idr_find at read/write/mmap to avoid the idr_find > complexity in case passthrough is disabled for that file. > > What do you think? > As I wrote above, this sounds unnecessarily complicated. Miklos, Do you agree with my interpretation of FUSE_DEV_IOC_PASSTHROUGH_CLOSE? Thanks, Amir.