Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp570912pxp; Wed, 9 Mar 2022 08:21:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEzBoGjwLFZFcwjKE91o+c/Z8yC9dxWoMNC8yDTBqIQJBWvUrFjPgfWZynEiSEI3hFRAYr X-Received: by 2002:a05:6402:11ce:b0:416:7b5a:a1cc with SMTP id j14-20020a05640211ce00b004167b5aa1ccmr180948edw.327.1646842915509; Wed, 09 Mar 2022 08:21:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646842915; cv=none; d=google.com; s=arc-20160816; b=Gqe7r+WTwUrRZbWI0SXeZVYXEj71JUxixPRDWt4fDIq2sM4ALS/lkKfAkh3LBDaMNr S5r6Y2CPvuHa93Inb8i8zmC2R1VuzioG8WZ7KOhF1XucGjLxLVDq3j+De97PjCza7Oek Oc0I+J2irUqbRCuRgMosD2IfQN9JT9ACjsJfax7eq9umdUzTzThf4fBOjCqVCtTNomFQ R0pHAdDLzBjYP9tGbBSkKLFVNPvqlVnzDQ3r0w5Gb9sQHsXBuZrMLWqr20DoOkRGD59z ug4vqoVxbsWmLulxZ+TU2MwpROSQM8LTXxYQnPhM5U0Mzu1ZbsfeOfjVOkoZmIMa4l2p rrag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-filter; bh=bCImYdsENS3tPMBV2uOd3Z13GABLrRutZzFjwCivDv0=; b=g3cdlH1kMSLAu+JK7z/qI0Dnp9KTdMcLFVLJQTInYFerrHrLTJIaJmBGqDiTmL7HqK CVDEASPkSpcK9IDowlm2vWdZ00xpZ7oSCJTrvbDoA0nxha7Qog/5UCbZFDKYbBjjaqbt kj6TKgCNGDqNhkmGXzOLdet96myyqeT+LCAQPTfRom82/pC4cUj8VAXPquu0oQHgqSsN r8rpwn2gqgo+mnGJLZ9VeYwZLPbXRpv+ZteypplS1xkfahoMecCg3AJauhCYp5KDY4qf gR8uAE1A68tbM+Q6jL8VnfkuRhyP/Inyjgf4RGDbkDkl7xXaVxYIEsIUx5kQpZVNpiyq lPhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b="L/X2XiNQ"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg6-20020a170907a40600b006db3accad46si1572089ejc.576.2022.03.09.08.21.29; Wed, 09 Mar 2022 08:21:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b="L/X2XiNQ"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231682AbiCIOUr (ORCPT + 99 others); Wed, 9 Mar 2022 09:20:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231248AbiCIOUq (ORCPT ); Wed, 9 Mar 2022 09:20:46 -0500 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B21AF4044 for ; Wed, 9 Mar 2022 06:19:47 -0800 (PST) Received: by fieldses.org (Postfix, from userid 2815) id 0153348FA; Wed, 9 Mar 2022 09:19:45 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 0153348FA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1646835586; bh=bCImYdsENS3tPMBV2uOd3Z13GABLrRutZzFjwCivDv0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=L/X2XiNQNXPHWpiNpaDBvGPdSxV/rva9GOPIKeYN5YLe0tc8rB/5sUboanwjhCW7Y SYnd7ghFp43SQO7hP78ZBAs9O5sXWkG4Q+Yg+RQNH7hUY5u3Tfj2VZhpv0MfhZxEhE ho1TgHn9rGwGNTs8KseDX8BI3d7qNhzkO7AH673A= Date: Wed, 9 Mar 2022 09:19:45 -0500 From: bfields To: Richard Weinberger Cc: linux-nfs , david , luis turcitu , david young , david oberhollenzer , trond myklebust , anna schumaker , chris chilvers Subject: Re: [RFC PATCH 1/6] Implement reexport helper library Message-ID: <20220309141945.GA6633@fieldses.org> References: <20220217131531.2890-1-richard@nod.at> <20220217131531.2890-2-richard@nod.at> <20220308214437.GB22644@fieldses.org> <692661836.127800.1646819014252.JavaMail.zimbra@nod.at> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <692661836.127800.1646819014252.JavaMail.zimbra@nod.at> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, Mar 09, 2022 at 10:43:34AM +0100, Richard Weinberger wrote: > Bruce, > > ----- Ursprüngliche Mail ----- > > Von: "bfields" > > On Thu, Feb 17, 2022 at 02:15:26PM +0100, Richard Weinberger wrote: > >> +#define REEXPDB_SHM_NAME "/nfs_reexport_db_lock" > >> +#define REEXPDB_SHM_SZ 4096 > >> +#define REEXPDB_INIT_LOCK NFS_STATEDIR "/reexpdb_init.lock" > >> +#define REEXPDB_DBFILE NFS_STATEDIR "/reexpdb.sqlite3" > > > > I don't know much about sqlite--why do we need to do our own file > > locking? If we do need to do it ourself, could we lock the database > > file instead instead of using a separate lock file? > > Concurrent access to the database is synchronized using a shared rwlock (on shared memory). > reexpdb_init.lock is used to make sure that creating and initializing the shared memory/lock > happens once. Could you point me to sqlite documentation that explains why the user would need to do their own locking? I assumed sqlite would do any necessary locking for you. It seems like a core function for a database. > > What are the two tables used for? Naively I'd've thought the > > "subvolumes" table was redundant. > > fsidnums is used to store generated and predefined fsid numbers. > It is only used in reexport modes auto-fsidnum and predefined-fsidnum. > > subvolumes contains a list of subvolumes which a are likely in use by > a client. Up start all these paths will get touched such that they can > be exported. The fsidnums also contains that same list of paths, right? So I don't understand why we need both. Also, if we're depending on touching all the paths on startup, something is wrong. What we want to do is touch the path when we get an upcall for the given fsid. That way we don't have to assume, for example, that the system will never expire mounts that haven't been used recently. > >> +/* > >> + * This query is a little tricky. We use SQL to find and claim the smallest > >> free fsid number. > > > > Yes, that is a little tricky. Is it necessary? My SQL Is rusty, but > > the database should be able to pick a unique value for us, shouldn't it? > > SQLite can generate a unique value, but we cannot select the range. > It will give a value between 0 and 2^64. > We need an id between 1 and 2^32. Surely that CHECK constraint doesn't somehow cause sqlite to generate non-unique primary keys? At worst I'd think it would cause INSERTs to fail if the ordinary primary-key-choosing algorithm chooses something over 2^32. --b.