Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gPToF-0008SP-0p for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Nov 2018 14:48:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gPToD-0007JA-Gm for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Nov 2018 14:48:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gPToD-0007J3-3n for pgsql-hackers@lists.postgresql.org; Wed, 21 Nov 2018 14:48:53 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gPToA-0004RW-4L for pgsql-hackers@postgresql.org; Wed, 21 Nov 2018 14:48:51 +0000 Received: by mail-lj1-x242.google.com with SMTP id s5-v6so5058921ljd.12 for ; Wed, 21 Nov 2018 06:48:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=flfei1PPpRjkKIY4YMYdFPYKzIFyaPws7pzFP0cgXb4=; b=s91aY4pzda/QaPLmH9KWtqOdKNFbFKSP30OR5GTtQSerFNCtWU32QHxSfQyFJ4ukXd YznfQTvcG4UfM1xxCuY9nkypnyqc7kHvb7IbU/XTwoDDVTb1zBIuHjOpC8gZpVcdIpO1 pBebPETZTIrslUMhmEDDfJkiSrpgiboa2xXJjYZjVJkdWvk+rSwJeBZZnDVaCTjFnQNU 2ltOrOBZlLDXcRNDkY1JOBZvbfVNLp5wRn83QPeZDP81wvHuZEPN7eb5CQ4qTinCt7YB JFbLrtEzt5s6hBGMAFmYyxSxgGVXupoTr6uO5OitfMlhjQosYaiwopmbZ0+EkLp0JQvz dYzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=flfei1PPpRjkKIY4YMYdFPYKzIFyaPws7pzFP0cgXb4=; b=AQoqbBlcTbStUz/CJ/qHq+RURj4C7+Sn9VJv7h0SNpVhmkuJbfOyURhVULv+JIjhbf VCasxdXi13XkCyAJpb2TJuN/f4tIoZF6HcOpttIWzx5SKfqRY9QljvwNjA763eVslPv7 5teOtX3WJ+Gbb+hLB2jm5JWzqp075ZblyRTJazEXeNt5HaqkYjmJQQl5ErLMTGFeYr+3 ZWQhKxi0PzghpMR1G22gGVe9v9HZU6+O9JCOGfMWsUdrf8r7FnWZvurLn8sqFTaigSBf IurrhNRnD5Y+5zarl5U4lkk9NoEhKs8RmT+nCay2i6ts8iVRB44AJWr9LZpRc3GtRDbz odMg== X-Gm-Message-State: AA+aEWaVMvFE1MDZyLsT1TiALiwQBkcYAOfmQ4zhQDyKLz8nBAFmObEq bfW2pcvpioKwlYLBQJgzYHDE/2BJwicP5WEGb14= X-Google-Smtp-Source: AJdET5du8c3CHo8fyY48GKRvso7o8ypKKn6bd5tI0bK9ayA7Xuaa2YoHaaMATIADpl4YcjlO8xgp62BcJvYgz8ckkq0= X-Received: by 2002:a2e:890b:: with SMTP id d11-v6mr4174008lji.113.1542811728029; Wed, 21 Nov 2018 06:48:48 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Robert Haas Date: Wed, 21 Nov 2018 09:47:44 -0500 Message-ID: Subject: Re: Control your disk usage in PG: Introduction to Disk Quota Extension To: hawang@pivotal.io Cc: "pgsql-hackers@postgresql.org" , Tomas Vondra Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Nov 20, 2018 at 2:20 AM Haozhou Wang wrote: > We prepared a patch that includes the hook points. And such hook points a= re needed for disk quota extension. > There are two hooks. > One is SmgrStat_hook. It's used to perform ad-hoc logic in storage when d= oing smgr create/extend/truncate in general. As for disk quota extension, t= his hook is used to detect active tables(new created tables, tables extendi= ng new blocks, or tables being truncated) > The other is BufferExtendCheckPerms_hook. It's used to perform ad-hoc log= ic when buffer extend a new block. Since ReadBufferExtended is a hot functi= on, we call this hook only when blockNum =3D=3D P_NEW. As for disk quota e= xtension, this hook is used to do query enforcement during the query is loa= ding data. > > Any comments are appreciated. +1 for adding some hooks to support this kind of thing, but I think the names you've chosen are not very good. The hook name should describe the place from which it is called, not the purpose for which one imagines that it will be used, because somebody else might imagine another use. Both BufferExtendCheckPerms_hook_type and SmgrStat_hook_type are imagining that they know what the hook does - CheckPerms in the first case and Stat in the second case. For this particular purpose, I don't immediately see why you need a hook in both places. If ReadBuffer is called with P_NEW, aren't we guaranteed to end up in smgrextend()? --=20 Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company