Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3480937pxp; Tue, 8 Mar 2022 15:33:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcHP2ucYqYdUpO1RkeersVhfynhwyqCbCTpmjZKtqNW18wDgKThHZPfPxAY2K3wE0FB44n X-Received: by 2002:a05:6a02:208:b0:372:c366:8ff4 with SMTP id bh8-20020a056a02020800b00372c3668ff4mr15855972pgb.76.1646782400017; Tue, 08 Mar 2022 15:33:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646782400; cv=none; d=google.com; s=arc-20160816; b=lvcFlAzBTYn8LvCIZKidBUH8aKU/qio37VrVIm9Z2Z3iIBW+D7YNf090z3Z+aWnotW /NkONwc0nrln6vggYRV6cgSNn6nJ4tQwDe33kdhpGS55y9G2PJKkHKvGhX3Pl0W0U0mA 5OgA76u1oj/MJLxym2mtdBxUCYnQufbhHoIVRXy8eeEeC5H9Quzn8R5Ik3pSfhSPGSy0 TOAy9FVaCeLf/mtDzKELXhrardNN60nxwYekMnw5EvsngIX+aDXIzcdr6Y5lx4HT9pmT ak/Z4YMefGZZF7KZZSyqzgw58tehqYzoOa2HL7jrchimTFd82ZbdVJs0FwJahg3js9oJ 6VXA== 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-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=LMblVJNZM1SsTP0rXRBEEG3hXbkUoxGHnxaWHCQg7+g=; b=vCfAhBptt1SVOMDJXbHkMsiaezBLMvz0BFjaa6iETRUNy0jcs4+7ItfhPpS3cAdwMn nVHBAfu72o78ePFv1ZdqGPRacDsio0rhhQzYjH6BHlQvMt3cz0tOwP/ByocK/FBczapd Rj/xAzirLB1qgDZCytuBs6cJwnvcdQVs8ObPEsRNksg4xTB1isX29cuy45FKa1UmWzSn hcqqyFQ/pcRPMoPEK3ndAHY4An5riSIXVfR3JBKD5GHwKm82L2lu15tvAQ0lJfjoCO/J eHL5U6RqRFy0b0hWwgzgud+3FjNpirbfZK3qIIpMDq1aIW8gk7w1HaM7PJrS/U3Tk4gD hqcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=baNJnUK5; spf=softfail (google.com: domain of transitioning linux-nfs-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d4-20020a170902cec400b00151bb1b5c96si324031plg.182.2022.03.08.15.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 15:33:19 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-nfs-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=baNJnUK5; spf=softfail (google.com: domain of transitioning linux-nfs-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B49386B096; Tue, 8 Mar 2022 15:21:14 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350427AbiCHVpf (ORCPT + 99 others); Tue, 8 Mar 2022 16:45:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346294AbiCHVpf (ORCPT ); Tue, 8 Mar 2022 16:45:35 -0500 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFC1A4D25D for ; Tue, 8 Mar 2022 13:44:37 -0800 (PST) Received: by fieldses.org (Postfix, from userid 2815) id 35F354B53; Tue, 8 Mar 2022 16:44:37 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 35F354B53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1646775877; bh=LMblVJNZM1SsTP0rXRBEEG3hXbkUoxGHnxaWHCQg7+g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=baNJnUK5quyNXxLjwzSUOMqZozaFq9ryKlfd/0kl8QhffUwTZBOsOyWc/ichpJoz6 sr94IqOBlm28/nuz/qJSNJ8I7fBbY4zewzmx4FmDM1oX9kAeWlSjrXTMGivKlh3r1U parYr+DTiNoz5SSloQGgFqmjUYmw8faw2jpaNeVA= Date: Tue, 8 Mar 2022 16:44:37 -0500 From: "J. Bruce Fields" To: Richard Weinberger Cc: linux-nfs@vger.kernel.org, david@sigma-star.at, luis.turcitu@appsbroker.com, david.young@appsbroker.com, david.oberhollenzer@sigma-star.at, trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, chris.chilvers@appsbroker.com Subject: Re: [RFC PATCH 1/6] Implement reexport helper library Message-ID: <20220308214437.GB22644@fieldses.org> References: <20220217131531.2890-1-richard@nod.at> <20220217131531.2890-2-richard@nod.at> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220217131531.2890-2-richard@nod.at> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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? > +static const char initdb_sql[] = "CREATE TABLE IF NOT EXISTS fsidnums (num INTEGER PRIMARY KEY CHECK (num > 0 AND num < 4294967296), path TEXT UNIQUE); CREATE TABLE IF NOT EXISTS subvolumes (path TEXT PRIMARY KEY); CREATE INDEX IF NOT EXISTS idx_ids_path ON fsidnums (path);"; I'd personally find it easier to read if these were defined in the place where they're used. (And, honestly, if this is just used once, maybe the definition is unnecessary.) What are the two tables used for? Naively I'd've thought the "subvolumes" table was redundant. > +/* > + * 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? > + * To find a free fsid the fsidnums is left joined to itself but with an offset of 1. > + * Everything after the UNION statement is to handle the corner case where fsidnums > + * is empty. In this case we want 1 as first fsid number. > + */ > +static const char new_fsidnum_by_path_sql[] = "INSERT INTO fsidnums VALUES ((SELECT ids1.num + 1 FROM fsidnums AS ids1 LEFT JOIN fsidnums AS ids2 ON ids2.num = ids1.num + 1 WHERE ids2.num IS NULL UNION SELECT 1 WHERE NOT EXISTS (SELECT NULL FROM fsidnums WHERE num = 1) LIMIT 1), ?1) RETURNING num;"; > +static const char fsidnum_by_path_sql[] = "SELECT num FROM fsidnums WHERE path = ?1;"; > +static const char add_crossed_volume_sql[] = "REPLACE INTO subvolumes VALUES(?1);"; > +static const char drop_crossed_volume_sql[] = "DELETE FROM subvolumes WHERE path = ?1;"; > +static const char get_crossed_volumes_sql[] = "SELECT path from subvolumes;"; ... > +/* > + * reexpdb_init - Initialize reexport database > + * > + * Setup shared lock (database is concurrently used by multiple processes), So, this should all work when rpc.mountd is run with --num_threads > 1? --b.