From nobody Mon Sep 23 10:40:27 2024 X-Original-To: freebsd-fs@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 4XBzzM2kyDz515YG for ; Mon, 23 Sep 2024 10:40:31 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XBzzM1pDSz4kkv for ; Mon, 23 Sep 2024 10:40:31 +0000 (UTC) (envelope-from avg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727088031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OsWrTJJa9P58TL+pLICC9TpMpqBsIYnqZn13Mhv7pw0=; b=wP1WVomxRsDjlJgKjYybAlS4F/DiiWB0IUGbKAlgkynLSAmigsiBQz9EAq3/XBYD5gLBbI kFIlk/BxJyO7JEu2K6juZzFHpsHWhx1HBwrSNOJLdFxpUTJya75ZQeaNxqPMd5LnTxr+ah QcFXvYcVaFIqNm0iegUT1WfHv4dOVkPITgJzvZ7F7yGqGBNV+mwvP9AMdsFfBysLTn/FbQ FmGSkVOEMjQ01fOQiaql28wR285z2atKDbScr6Vd8sZZzpZo+BdfvuAq7W9i3PjCocWId6 i24xapqMrhaT6IjHu8AiylmDS18DEFslBvzQDN0HWzZoWwHBh/XtZ4cKxodM9g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727088031; a=rsa-sha256; cv=none; b=YLcmQ2VrCisQwZ3FvBU45SaueKO6Viq6gJGSswqPY9FppXL4YtONBuKeUbTX28Ubup6FGN hKhfNV/jjSVBnPHXPIK2bvAMNDXnRayUevWVmAMIzym6rVda1gRlik1l9CJXJNAZHBVsuA u/8jT6yz1chTu+Mpy4EZMMJwETalaJ1FlCIL5JWyrBhJusBQRJXhROZ/hrABz2izkRBIHu xOfzps57cZ/2AHlKE+Hn1bE0Yual8MhZt2NuZT7I86BWbMctuMW0r7mCDD4kH5FmCLLruN sg7eQmyt00Of+C6/TRpHQa+DW68jsl1rCxyxb9g2IxeRzRea3FKMsQDAopz+nA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727088031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OsWrTJJa9P58TL+pLICC9TpMpqBsIYnqZn13Mhv7pw0=; b=kfNfY49Yei5c+E+wN3mfHU1V0fiaK1yeYNWRuC4IEzIAb0dsVm9KfjaV79WZRIXIV5wpJB rq6LT8LQyYqWzOl25CqWDDbRALbvk0u4Q46n1ZdGf9itFCxbTgWMZlMk23FgbqMRConZPw eI0cXTm5clDR8n2GNwdkeYlYKFGBtP3OTR5OXlTVMnqt8W2YtGMC6+wyiXdOK32tbAXyGM XDWRtTJJX90wajHoOo/XCa+lwDRqI3rurMrCnneNWoIqI4BiRhyilrCJ1M7g/uHGZjOvwF bfi38EW/d19XvpwM9OQcTH6AK97XsUGqzjdQYvL22BEyCsVCRZTNK03rI8QLNg== Received: from [192.168.0.88] (unknown [93.188.39.137]) (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 did not present a certificate) (Authenticated sender: avg/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4XBzzL6mLmzjcy for ; Mon, 23 Sep 2024 10:40:30 +0000 (UTC) (envelope-from avg@FreeBSD.org) Message-ID: <8e3488d7-9e8a-49a5-9e16-53137eb6d7fc@FreeBSD.org> Date: Mon, 23 Sep 2024 13:40:27 +0300 List-Id: Filesystems List-Archive: https://lists.freebsd.org/archives/freebsd-fs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-fs@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: FreeBSD Filesystems From: Andriy Gapon Subject: OpenZFS/FreeBSD only: potential space leak with async_destroy Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit This is a so far theoretical only concern based on a real problem that I encountered at work. It seems that only on FreeBSD ERESTART == TRAVERSE_VISIT_NO_CHILDREN == -1. From a quick search, Linux and illumos use positive numbers for ERESTART. The potential problem is that dsl_process_async_destroys uses bptree_iterate to traverse blocks of a destroyed dataset. bptree_iterate internally uses traverse_dataset_destroyed and all the common traversal machinery. If dsl_scan_free_block_cb decides that the async destroy activity should stop (pause) in the current sync pass, then it would return ERESTART. traverse_dnode can misinterpret that return value as TRAVERSE_VISIT_NO_CHILDREN and stop visiting data blocks while continuing the traversal. As a result: 1. bptree_iterate may continue traversing despite dsl_scan_async_block_should_pause; 2. bptree_iterate may believe that it visited data blocks when, in fact, they were skipped. A test would require destroying a large enough dataset (on a throwaway pool), waiting for feature@async_destroy to switch from active to enabled and then checking that the pool's freeing property is not zero. What do you think? -- Andriy Gapon