From nobody Tue Apr 05 20:57:29 2022 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 932771AA0606 for ; Tue, 5 Apr 2022 20:57:47 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KY0Mt3sfcz4j1g for ; Tue, 5 Apr 2022 20:57:46 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-de3ca1efbaso724920fac.9 for ; Tue, 05 Apr 2022 13:57:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UZjsFujz+Rz+2b/FCym41tIixDj5aaQzaoCFqa3u7jY=; b=A9fybsfJ84PuE0RDvLNQtnkDIW1r9ykRvWH8lraW2JG5owIkbpn0dfM2USEuqZTaSi 50v7RCUHjPUULndkoguHIiFDcyxiPVjxwBsJkHDBXETeyGa3sUhWL6e+klHZqzrQcdGH M9nKq6wf8sY5qhncF4CYRQs0Qt0wymO9ySPbAO1DWmDYqfqi2XBRjeyYeZSQOPiDCO9C i0SLiIYzbuW1x8GIOBxDeR45YAd8SuCPkalpSJyxJggMeo2JAjpFUwMz1q5UaAGbR0TT koeG/hKyQwSo/60BpSoL4rKFzebyH0RcjJwiQKjt3KvdPWz6y9s6HX14k2Ts67F6SYBg dNxw== X-Gm-Message-State: AOAM533hm7zScgFfaOhpAG2joieNbyyvB1aJ7E4H5lAtAPupsF8E5xHf mubgOKNp2siJzqw59HBEkN990k6ibz3TI0OFEYsHVyr8 X-Google-Smtp-Source: ABdhPJxn/ofE5YOj+LpCjAwI0Nu2EP0Nx2O1ve37Wf3EY5Jq0X1lH11vGBhifbmzZ8wJ1B8dOB8jSkQmtGoRI9t98RE= X-Received: by 2002:a05:6870:a2d2:b0:d7:60ca:5065 with SMTP id w18-20020a056870a2d200b000d760ca5065mr2549739oak.72.1649192260230; Tue, 05 Apr 2022 13:57:40 -0700 (PDT) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 References: <03F69985-51A4-4A35-801C-CFC7B40B766D@dons.net.au> In-Reply-To: <03F69985-51A4-4A35-801C-CFC7B40B766D@dons.net.au> From: Alan Somers Date: Tue, 5 Apr 2022 14:57:29 -0600 Message-ID: Subject: Re: PEFS and advisory locking on ZFS To: "Daniel O'Connor" Cc: freebsd-hackers Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4KY0Mt3sfcz4j1g X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of asomers@gmail.com designates 209.85.160.42 as permitted sender) smtp.mailfrom=asomers@gmail.com X-Spamd-Result: default: False [-2.93 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; FREEFALL_USER(0.00)[asomers]; FROM_HAS_DN(0.00)[]; RWL_MAILSPIKE_GOOD(0.00)[209.85.160.42:from]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-0.94)[-0.937]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[209.85.160.42:from]; NEURAL_HAM_MEDIUM(-1.00)[-0.997]; MLMMJ_DEST(0.00)[freebsd-hackers]; FORGED_SENDER(0.30)[asomers@freebsd.org,asomers@gmail.com]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[asomers@freebsd.org,asomers@gmail.com]; FREEMAIL_ENVFROM(0.00)[gmail.com]; RCVD_COUNT_TWO(0.00)[2] X-ThisMailContainsUnwantedMimeParts: N On Tue, Apr 5, 2022 at 7:19 AM Daniel O'Connor wrote: > > Hi, > I maintain the PEFS port/project (https://github.com/freebsd-pefs/pefs/) which is an encrypted file system which transparently runs on top of other file systems. > > I've updated it to work OK however someone has discovered that if it's running on top of ZFS then locking doesn't work, >1 process can own a lock (as tested with lockf) > > It FreeBSD 13.1-RC1 (tested with releng/13.1-n250053-6fe29001573 GENERIC arm64) - when testing on -current (14.0-CURRENT #1 main-3468cd95c) it does work. > > I tried implemented VOP_ADVLOCK but it didn't help (not really surprising but still). > > The test is pretty simple, if /testtank is ZFS, then: > > # Create crypto FS > sudo mkdir -p /testtank/test/pefs > echo test123 >keyfile > sudo pefs addchain -fZj keyfile /testtank/test/pefs > > # Mount it and add the key > sudo pefs mount /testtank/test/pefs /testtank/test/pefs > sudo pefs addkey -cj keyhole /testtank/test/pefs > > # Test locking > sudo lockf -k -t 0 /testtank/test/pefs/lock sleep 5 & > sudo lockf -k -t 0 /testtank/test/pefs/lock echo foo > > When it's working the second lockf will print: > lockf: /testtank/test/pefs/lock: already locked > > ZFS itself is fine, the lock test passes if PEFS isn't mounted, and on the same version PEFS on UFS works fine also. > > I plan on bisecting it but if anyone has a suggestion I'm all ears. > > Thanks. > > -- > Daniel O'Connor > "The nice thing about standards is that there > are so many of them to choose from." > -- Andrew Tanenbaum Does it use flock or fcntl with F_GETLK/F_SETLK? Or worse, does it mix the two? Is fusefs involved? And does it work on top of UFS?