Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2033806rda; Tue, 24 Oct 2023 10:12:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUHz9rYO15xTlxS5VZQf2ocYY18u190D2SU+9S7DPSyc9Ygk2yRad2mHyzXK6zbT7XvDxe X-Received: by 2002:a17:902:f7cd:b0:1ca:86a9:cace with SMTP id h13-20020a170902f7cd00b001ca86a9cacemr10275846plw.2.1698167569592; Tue, 24 Oct 2023 10:12:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698167569; cv=none; d=google.com; s=arc-20160816; b=QYxT+hJMNJ0VXWxU9DQlwEusGWCJRrVHDoCh/UwrxGwDcI2oHsA2Gt1LosbfV4BcAh I9sNRnbbuizMVbwsrKP/Y28rtzDwpeSA2c+wlxyL/FBW4uHd2e/qD0iaiew/uqMhRIMg OMCmG4Owy8n6qP3EUQIX3qO7r4yf8gS6cUbDogl1ahYe0O3U2Fb2/gEIZH21UmIhBwE1 CYicP/qouxJ1ZNsn4EEjVstF+n4jZ3LuZg03vIJxphJ5335l7qmDQ1Et9GKF03EQKsS3 08javKQF4Lpyhf1BR9uFelX83MngpXfCIX1E7V0L+Dmiz8mkKKumRX6Nm0hSQg1S1+Fm 33Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=0APWsN9sAkS47gK58kM+OT6Zez1NqQFELwGD0pR6lhY=; fh=49dYkGGJhhLbKegsH1Wk/0C4D9gWJPELGgGARlTIwkY=; b=LVwZnj1AsbWnjLqws6hwPZn+4GpOnL7qzIK83a6Xm+92cPqhbwXrv/ZsuJySBbsx9b Vnw2exj7EVSXn/sjcxr6NiBB83defyZea4RhC5BJJByZO3GIG4iTBZ1LDvxzKe7vZvHB 2T26CmUz7VJuL0LFiBXeGZ2XP+ipOMcVSuDRyuCPYlZZf6NWnKX8dCEV88JimKssmaja i8vLdtcKNVMHAmqDm9fKE3GBrHnXrcGdK08reIaNe+2vQtShgu838H+nzN8Re3ooqHtW SNno+kOeuFSkhkf7j2zerQxLlf2lc+ZVbrhlkY6V4XnAy3OuSVISHoIJ2RU4zOPpQhCp ZTMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bUwq3TU0; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id z5-20020a170902708500b001b9be3b94dfsi8318282plk.268.2023.10.24.10.12.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 10:12:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bUwq3TU0; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6F889803D8CE; Tue, 24 Oct 2023 10:12:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234423AbjJXRMf (ORCPT + 99 others); Tue, 24 Oct 2023 13:12:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234841AbjJXRMe (ORCPT ); Tue, 24 Oct 2023 13:12:34 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFE86129; Tue, 24 Oct 2023 10:12:32 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id af79cd13be357-77784edc2edso292355285a.1; Tue, 24 Oct 2023 10:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698167552; x=1698772352; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0APWsN9sAkS47gK58kM+OT6Zez1NqQFELwGD0pR6lhY=; b=bUwq3TU0SS3UnH/imwup379EfXrD+G67Y3/4sLZEJVBrA6NV5Ai/isGtBMc4GY667Y bTDJu9klfgF007MFRMm4RB6loNjz9UwXAC20QLQEsddP8hO/3V6oEympeHkcMFruV47r NATeydlvT93kBOTz5yM8GXh9H2dtwUzDvPhMwC7jsWIwbpizecaKJpKLqV6kaYOcjWzq eAxIJ+ddf+f0DXeun3IATj4VuBDRfki3Yp7hg5i2IUV7QFyyAWJpu0P9jK9j6+tBqcah u/znxa/Tj362RDyroywXNXjJNbLGWvek4btha0B3PsK/XO6kjzK8dWKrzyfz5A5Ne9GU aLmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698167552; x=1698772352; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0APWsN9sAkS47gK58kM+OT6Zez1NqQFELwGD0pR6lhY=; b=U6uYOaKxHPt1qVTsHl1tWDxZBEZf01YkkuD4y3JdRhHz4efsZbjsuwTSCqoKYUn29B dOtX1OuviIFRoTSlUIJmuJCD9I7DJa7GvzsqxawRZexRrWFx/HQMtgPOhg5UcFqq6DMj obtxI6zdtH0EAMtzQYkF4F3ScNrx/EGI/p9Yv5E/rVLBZg312h7mUxouxxRDSiHWZFmJ 7KUiWF9N2AQLJv3A1WYMCz1g/YgcJQ8M+sYA0R+m8rtyFu0QsZ60M9Rrn0+8RKH5V4t+ 4pxVqXFt0Ww9uJW/Q3CSfupZ3MVI5VQ4LJ9ZVqVKBceuThQiJzYmVOpYzuDkQV2QCTjm phjQ== X-Gm-Message-State: AOJu0YyL3lDhITs59UOKrH6+RBJEU742Ad5BVPOk9Bau0p4iGx4iFyr6 5hbuBXNpn0+xXFHCQtefjpMM4Tn20bMTkGtULe0= X-Received: by 2002:a05:6214:ca6:b0:649:8f20:5528 with SMTP id s6-20020a0562140ca600b006498f205528mr17988802qvs.60.1698167551591; Tue, 24 Oct 2023 10:12:31 -0700 (PDT) MIME-Version: 1.0 References: <20231024110109.3007794-1-amir73il@gmail.com> <1CFE0178-CE91-4C99-B43E-33EF78D0BEBF@redhat.com> <2382DA9B-D66B-41D9-8413-1C5319C01165@redhat.com> In-Reply-To: <2382DA9B-D66B-41D9-8413-1C5319C01165@redhat.com> From: Amir Goldstein Date: Tue, 24 Oct 2023 20:12:19 +0300 Message-ID: Subject: Re: [PATCH] nfs: derive f_fsid from server's fsid To: Benjamin Coddington Cc: Trond Myklebust , Anna Schumaker , Jeff Layton , Chuck Lever , Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 24 Oct 2023 10:12:35 -0700 (PDT) On Tue, Oct 24, 2023 at 6:32=E2=80=AFPM Benjamin Coddington wrote: > > On 24 Oct 2023, at 10:58, Amir Goldstein wrote: > > > On Tue, Oct 24, 2023 at 5:01=E2=80=AFPM Benjamin Coddington wrote: > >> > >> On 24 Oct 2023, at 7:01, Amir Goldstein wrote: > >> > >>> Fold the server's 128bit fsid to report f_fsid in statfs(2). > >>> This is similar to how uuid is folded for f_fsid of ext2/ext4/zonefs. > >>> > >>> This allows nfs client to be monitored by fanotify filesystem watch > >>> for local client access if nfs supports re-export. > >>> > >>> For example, with inotify-tools 4.23.8.0, the following command can b= e > >>> used to watch local client access over entire nfs filesystem: > >>> > >>> fsnotifywatch --filesystem /mnt/nfs > >>> > >>> Note that fanotify filesystem watch does not report remote changes on > >>> server. It provides the same notifications as inotify, but it watche= s > >>> over the entire filesystem and reports file handle of objects and fsi= d > >>> with events. > >> > >> I think this will run into trouble where an NFSv4 will report both > >> fsid.major and fsid.minor as zero for the special root filesystem. W= e can > >> expect an NFSv4 client to have one of these per server. > >> > >> Could use s_dev from nfs_server for a unique major/minor for each moun= t on > >> the client, but these values won't be stable against a particular serv= er > >> export. > >> > > > > That's a good point. > > Not sure I understand the relation between mount/server/export. > > > > If the client mounts the special NFSv4 root filesystem at /mnt/nfs, > > are the rest of the server exports going to be accessible via the same > > mount/sb or via new auto mounts of different nfs sb? > > If we cross into a new filesystem on the server, then the client will als= o > cross and leave the "root" and have a new sb with non-zero fsid. > > > In any case, f_fsid does not have to be uniform across all inodes > > of the same sb. This is the case with btrfs, where the the btrfs sb > > has inodes from the root volume and from sub-volumes. > > inodes from btrfs sub-volumes have a different f_fsid than inodes > > in the root btrfs volume. > > This isn't what I'm worried about. I'm worried about the case where an n= fs > client will have multiple mounts with fsid's of 0:0, and those are > distinctly different mounts of the "root" of NFSv4 on different servers. > fanotify_mark() fails with -ENODEV when trying to watch an sb with zero f_fsid. This is the current state with nfs, so there is no concern for a problem - it just means that fanotify will not be able to watch those mounts. It's not great. > > We try to detect this case in fanotify, which currently does not > > support watching btrfs sub-volume for that reason. > > I have a WIP branch [1] for handling non-uniform f_fsid in > > fanotify by introducing the s_op->get_fsid(inode) method. > > > > Anyway, IIUC, my proposed f_fsid change is going to be fine for > > NFSv2/3 and best effort for NFSv4: > > - For NFSv2/3 mount, f_fsid is a good identifier? > > Yes, it should represent the same filesystem on the server. You could st= ill > get duplicates between servers. What's returned in the protocol's u64 fsi= d > goes into major with minor always zero. > > I'm sure there was discussion about what implementations should use long > ago, but that predates me. > Yeh, duplicates aren't great when watching two different sb with same f_fsid, it is not possible to know which sb the events came from. However, the process setting the sb watches can know that in advance. > > - For NFSv4 mount of a specific export, f_fsid is a good identifier? > > Yes, but if the specific export is on the same server's filesystem as the > "root", you'll still get zero. There are various ways to set fsid on > exports for linux servers, but the fsid will be the same for all exports = of > the same filesystem on the server. > OK. good to know. I thought zero fsid was only for the root itself. > > - For the NFSv4 root export mount, f_fsid remains zero as it is now > > Yes. > > > Am I understanding this correctly? > > I think so. > > > Do you see a reason not to make this change? > > Do you see a reason to limit this change for NFSv2/3? > > I'm not familiar with fanotify enough to know if having multiple fsid 0 > mounts of different filesystems on different servers will do the right > thing. I wanted to point out that very real possibility for v4. > The fact that fsid 0 would be very common for many nfs mounts makes this patch much less attractive. Because we only get events for local client changes, we do not have to tie the fsid with the server's fsid, we could just use a local volatile fsid, as we do in other non-blockdev fs (tmpfs, kernfs). I am not decisive about the best way to tackle this and since Jan was not sure about the value of local-only notifications for network filesystems, I am going to put this one on hold. Thanks for the useful feedback! Amir.