Received: by 2002:a05:7208:c24f:b0:81:d631:dc8 with SMTP id w15csp406085rbd; Thu, 4 Apr 2024 12:53:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVqMZsGUa9UyHi0dQcryE0MkPWo4QWSiYv36+Mw6OuX4LrpHHrJSx/jagqqs5Q7jSSrB6DS6tlDzNlfG+kfXpewwRKFV30ImpKEUFLgQA== X-Google-Smtp-Source: AGHT+IGbQfdBegZO9bohTDf2J4W67fW+yuUMHOdU0UVbo1fGyjfTfalBsF2vJ1HbqK6SShjR4Mbq X-Received: by 2002:a17:902:dacd:b0:1e2:a5c9:7048 with SMTP id q13-20020a170902dacd00b001e2a5c97048mr649369plx.26.1712260415666; Thu, 04 Apr 2024 12:53:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712260415; cv=pass; d=google.com; s=arc-20160816; b=sI6mkL0q7agxXpnbLbMtpk2vELQLtaWUgYLtDTI/VAQ662TbKnyVGp9c9IlK8ctBU4 e2C9567p2qs6TXf3R4CSxvfOdy8X7Vtf6sgUMitMvj5I6Y+8N4SnfJywJMJDpwnfzETB TgheZGcAX9wzuswZKb+hTsimeEd5JSq4DmH0tvan4n5o+UsctStNDMDRB8j1ejuTn3fI Cd4Y8BKk0wrh81DjXD6faBWTUZblXFI7u7Kn67tfX0yI8aYUA9m+9txK4WUqTtrzL8Hb WAogUYNhaySvOoXKHLK5WMrh6crgoe9OxhSlkMig5cvYI+IA93JwoFBo6o5DRzVxu4sx 9Vkg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :reply-to:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature:dkim-signature:dkim-signature; bh=0kGyYdvz1lGwPR6FgbkygCOdLQOLaJs4yjJ3ECXl6LI=; fh=oAx+754D4RHgKtrCNslHWncpPdPtaPyUQ2piX9avtGU=; b=k1xwV/9AdM1AZWTLBihe5hI7wCdRsEbHOgA15E2txIDXGg+hdHstEzqeoov/Vk2bcU iu9+irGJB3LqdxgUY9nXzdytEeXrT79K5uCry+n9UnbqVU/iP1F+KZd6CLJb1lhWGSUC elqdGzSjFYqaCdaenRoL+U21x+MJRJiTSCPOp7zbpQ3BPv2eQ3bx2xLkOZA9MEebZ6zU Vk0IbkWG7SJ2DXia4CR06Cg2akchJkGRDHO6IuS2fkr8y2eZNh/TgHsqoObpgw71WF5y eFtkLEh1zQ0qP0F2WG4GD7O1MF89w0+X46fBsgZtB74m3RPpn1rnjggvHIDw3yoh6gy4 F0fA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="nj/C3MAl"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ji3QTxuq; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-132060-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132060-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id mc6-20020a1709032b0600b001e2a41d20f0si11462plb.373.2024.04.04.12.53.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 12:53:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132060-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="nj/C3MAl"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ji3QTxuq; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-132060-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132060-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5695E282BC5 for ; Thu, 4 Apr 2024 19:53:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ADFCF12EBD0; Thu, 4 Apr 2024 19:53:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="nj/C3MAl"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="PP4L2GS8"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="ji3QTxuq"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="Kwfam1vJ" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E92CA74C14; Thu, 4 Apr 2024 19:53:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712260404; cv=none; b=aBHU6zlCNq2ehSLaZw5Yccuf0w9f1gBGOlrVnAs4qj3FWGA6v90ujSiWMCefzAeeZu90728huDo3oWB3mMpUZqP0UOj/NsNd4fcsgg84h8Q1Um87DVLSq+R0OQo1KHBmeriBT/hJaH3Ltcuoxm7+IIaptxvqClQX0g5O7XA+oXA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712260404; c=relaxed/simple; bh=WIaxxb/wJKgOnX2AIsmocmXM/m0z3iob9NXxQddI4Pg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CZoAVwnHGAJE41mhjTP+4ISLlCHMpOBjGznWfiM4yemOoVTWkcmrGcMiVukkaDsLhYGNp/KzS5zuF6eohMwHKokfqrmGfF3Xg2kTwKQAbJP5j4J0rG5JflByDwEhNYAb1w+nDNCFVXayiAQcyGsBCI5gU98JnfIBRKI/RywOIzA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=nj/C3MAl; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=PP4L2GS8; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=ji3QTxuq; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=Kwfam1vJ; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (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) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DFF871F441; Thu, 4 Apr 2024 19:53:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1712260401; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0kGyYdvz1lGwPR6FgbkygCOdLQOLaJs4yjJ3ECXl6LI=; b=nj/C3MAlqmkQc/GHgjaqRmYlbJS+5xTV1FMACJvdtg8riSwbl++lq296aqqMGgyVrvVJC+ g70q7Vn4mDLP5A5HEt0Ei/di0p/ZpZI4M7Ph4s/OBODN9ToGvX17KRfxIaUd+FDzzG/Lec vmNUvz2jeguhSMPPHk6DOKhGyrgtkg4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1712260401; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0kGyYdvz1lGwPR6FgbkygCOdLQOLaJs4yjJ3ECXl6LI=; b=PP4L2GS8ki1HoCI3//JngIKC4kPQe4Y2WWYWVHX2hQ1snir6WrP+yDv2IDE0jK5yQT9oFr AjKHp1X2QpNTkVDw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ji3QTxuq; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=Kwfam1vJ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1712260400; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0kGyYdvz1lGwPR6FgbkygCOdLQOLaJs4yjJ3ECXl6LI=; b=ji3QTxuqAvPTAwRGLGMxv6NvIlKIvxIauFBNnrqBXlle6B5cnXc163/s7WIjZH/fdlG+uL r/+6ACCwIy+WHlSgHvSJDQe23uCaCHtAitBgBANDtAn7deEPJ9h2jE87HqtwC3r+Fb2emb 5m4G4RYKxYU7dwIq5h5TSLGEzqwxjCo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1712260400; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0kGyYdvz1lGwPR6FgbkygCOdLQOLaJs4yjJ3ECXl6LI=; b=Kwfam1vJR4+biIZroMqZaewwhFLWPbJLzQxsjs4IEXmgvyj6PnMIiIMfEOivT6zj8icM7p xM7jzxhWCQ61E2Dg== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (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) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id C4F6613298; Thu, 4 Apr 2024 19:53:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id wxDyLzAFD2ZSbAAAn2gu4w (envelope-from ); Thu, 04 Apr 2024 19:53:20 +0000 Date: Thu, 4 Apr 2024 21:45:58 +0200 From: David Sterba To: Johannes Thumshirn Cc: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg , Naohiro Aota , hch@lst.de, Damien LeMoal , Boris Burkov , Johannes Thumshirn Subject: Re: [PATCH RFC PATCH 3/3] btrfs: zoned: kick cleaner kthread if low on space Message-ID: <20240404194558.GK14596@twin.jikos.cz> Reply-To: dsterba@suse.cz References: <20240328-hans-v1-0-4cd558959407@kernel.org> <20240328-hans-v1-3-4cd558959407@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240328-hans-v1-3-4cd558959407@kernel.org> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) X-Spam-Flag: NO X-Spam-Score: -1.38 X-Rspamd-Action: no action X-Rspamd-Queue-Id: DFF871F441 X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-1.38 / 50.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; HAS_REPLYTO(0.30)[dsterba@suse.cz]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; BAYES_HAM(-0.17)[69.78%]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RCPT_COUNT_TWELVE(0.00)[12]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:98:from]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:98:from]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; REPLYTO_ADDR_EQ_FROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap2.dmz-prg2.suse.org:helo,imap2.dmz-prg2.suse.org:rdns,suse.cz:dkim,suse.cz:replyto]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.cz:+] On Thu, Mar 28, 2024 at 02:56:33PM +0100, Johannes Thumshirn wrote: > From: Johannes Thumshirn > > Kick the cleaner kthread on chunk allocation if we're slowly running out > of usable space on a zoned filesystem. For zoned mode it makes more sense, as Boris noted it could be done for non-zoned too but maybe based on additional criteria as reusing the space is easier. Also cleaner does several things so it may start doing subvolume cleaning or defragmentation at the worst time. > Signed-off-by: Johannes Thumshirn > --- > fs/btrfs/zoned.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c > index fb8707f4cab5..25c1a17873db 100644 > --- a/fs/btrfs/zoned.c > +++ b/fs/btrfs/zoned.c > @@ -1040,6 +1040,7 @@ int btrfs_reset_sb_log_zones(struct block_device *bdev, int mirror) > u64 btrfs_find_allocatable_zones(struct btrfs_device *device, u64 hole_start, > u64 hole_end, u64 num_bytes) > { > + struct btrfs_fs_info *fs_info = device->fs_info; > struct btrfs_zoned_device_info *zinfo = device->zone_info; > const u8 shift = zinfo->zone_size_shift; > u64 nzones = num_bytes >> shift; > @@ -1051,6 +1052,11 @@ u64 btrfs_find_allocatable_zones(struct btrfs_device *device, u64 hole_start, > ASSERT(IS_ALIGNED(hole_start, zinfo->zone_size)); > ASSERT(IS_ALIGNED(num_bytes, zinfo->zone_size)); > > + if (!test_bit(BTRFS_FS_CLEANER_RUNNING, &fs_info->flags) && > + btrfs_zoned_should_reclaim(fs_info)) { > + wake_up_process(fs_info->cleaner_kthread); You can drop the BTRFS_FS_CLEANER_RUNNING condition, this is not a performance sensitive where the wake up of an already running process would hurt. > + } > + > while (pos < hole_end) { > begin = pos >> shift; > end = begin + nzones; > > -- > 2.35.3 >