Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796135737; b=SCmdTfVU7BreIYc0as/5iRxGXTI+CZA2qDU5yFeRWUXIdKdhQMjHl8K17Q3Yv1E0Xfvt 8wXmOCfqeROCItFNWnfj9LUV1O2iv8YZoBVwwsPNybQ7w8EUGT/j9vbeUb4h8RO+boEtB h5zLoyIGggeTl1CLHPC6iqeHibU1p0N6G7O2kiyno2OKY1LvZzM6bFyxRrCBAUTBeSO18 eUgRiFwdiQ7StDIOL8mFQ/ELTd7HnQEvT82dFH5xsvRt2ZwW9O1iiomIVu6vTX7hBr99t 1tC/hW+Ipy1FwruuxKy/OgK1uZi9XDDsN31uEX67BPeBgpCcEnqAJYY8Uq8hYX+Z2kw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796135737; h=DMARC-Filter:Received:DKIM-Signature:DKIM-Signature:DKIM-Signature: DKIM-Signature:Received:Received:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:X-Developer-Signature: X-Developer-Key:Content-Transfer-Encoding:X-Spamd-Result:X-Spam-Score: X-Spam-Level:X-Spam-Flag; bh=1lajEFPbZglF/YQ0on/3zxKjvkfAmvhLd4bUIOjXAB0=; b=GasuKuH9VumcSoi9vA6Ozaf3alrPWCM1sTOGAuZ+SQVlu41Asn6V+/+Lf1pSzlULe/Qt sABGMDzpJhg8rz+z83HqZwXkyZlfsh6ORqG127jTYVsMrvvUOSeg71bvrp/+n9bPQRedI vbpUsQxMTLNKmMLyFNi4wleOu3F273Ac27U5a0hn1B2MuZFKvpkFQ3eXjuWDcpNlZ6Ngx fyajnOM5SPICrOU5H+sk9C3B9OSTFtCizsA6DsaDwNh1Zl1af7GeX6WRVgN1T1c1H7DsD 7wB0jM0PSn3ElLjAKwA6UmvJxNDvcHSUNfy0AUPDBrEFniRqY2Z0oYXICF58KE+7FyQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=JhTazfwQ; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=kGgTKb3L; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=balG3TCR; dkim=neutral header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=tWr6akCT; arc=none smtp.remote-ip=195.135.223.130 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2590606A338 for ; Tue, 1 Dec 2026 14:35:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B2590606A338 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=JhTazfwQ; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=kGgTKb3L; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=balG3TCR; dkim=neutral header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=tWr6akCT Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (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-out1.suse.de (Postfix) with ESMTPS id A63FA222AA; Tue, 1 Dec 2026 14:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1796135734; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1lajEFPbZglF/YQ0on/3zxKjvkfAmvhLd4bUIOjXAB0=; b=JhTazfwQs0mK1T+k8BhEItHMVbSBs/gMmXLmYhLM2tVqSaBEMsoRv+FRBxNNITvfaN3N5b dKztX4UgkaJ3kIl9XTvC1TNDBB/POM2+eNSLp7bJrtoJSmsKvUbwU7giChdS5ZIWkZzU8d JQ7aTaa3WZTUSQ6dmZPnnYQr0cZlDfo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1796135734; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1lajEFPbZglF/YQ0on/3zxKjvkfAmvhLd4bUIOjXAB0=; b=kGgTKb3L96B4GQfqCWDG7ix/h5AYm9aPfBLGssi5eFYck8uvyqJlFY23otnkb/zAVyschl mW5xzJ+APaHtnXCA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1796135733; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1lajEFPbZglF/YQ0on/3zxKjvkfAmvhLd4bUIOjXAB0=; b=balG3TCR0NeIzW8foDWqYl4eQnbW8kCX7rhpQ+bYOkWesNcG0pYYd4RQ4xvIT7uZUV9hA4 EohVTIik8aZKAH0zslyS/ooFcyNbyohyjqjXVlkBRyCC4jeTJ8zI4FuE7sE28RSOPvftjS Mpymxq/jFlElOvnVOvfW1Wq7SDL8srA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1796135733; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1lajEFPbZglF/YQ0on/3zxKjvkfAmvhLd4bUIOjXAB0=; b=tWr6akCTpVvWUZza8z0DuvzSERstl4MiX53oQ5h+eaEM9EOHesi0O7VFKzC7fDhmCwHKFZ USoEER5/pbO0OnAA== Received: from imap1.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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 72EDC134E9; Tue, 1 Dec 2026 14:35:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id nVMEFDXbDmvxVAAAD6G6ig (envelope-from ); Tue, 01 Dec 2026 14:35:33 +0000 Received: by quack.suse.cz (Postfix, from userid 1000) id 0375C5153B; Tue, 01 Dec 2026 15:35:32 +0100 (CET) From: Jan Kara To: Christian Brauner Cc: , Christoph Hellwig , , Mikhail Rudenko , Andreas Gruenbacher , Jan Kara Subject: [PATCH v5 0/8] fs: Deferred inode reclaim Date: Tue, 1 Dec 2026 15:35:02 +0100 Message-ID: <20261201105733.18997-1-jack@suse.cz> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5107; i=jack@suse.cz; h=from:subject:message-id; bh=ltb0X/POX2cFR6pjjUJklFMr3awvObJ8EDusmL7AOSQ=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBrDtsWFsRRGT1ni8GNVghC8I32Q6bky8MoAvtoA Hbb/SDeLlqJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCaw7bFgAKCRCcnaoHP2RA 2W9kCACF/a1ShhC//tibnUDe4aHvA1YKOFTdUQ/PUveL8d/4oqcbAReg3/Drr1J4KGFOv78pa9T W2DtQennNv38iiaZfuQdV46jxK+iZzP0qxoAREcqKwSOPQxiVTuyCOSSChV4JI/zPNstYt4JK91 FH4SM0DGyGF9HBWraqKZ0Gmx7rCZ/Ph/75InNbBJgNkJwRsfa0+/613rshVmUALyOn9ppLas6Jl 2JAnnfTy2uflWjr4G3GxTKAp71RQrHgaMxudCK0OycFhL8URpJQpntBUrlKxP3ep7PPq7z77+e3 ipPBA49NoHcogeDctuEnD4ozT5SIriuii02iDbdGNw0zsuzT X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-11.80 / 50.00]; SUSE_INTERNAL_BYPASS(-9.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[7]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo] X-Spam-Score: -11.80 X-Spam-Level: X-Spam-Flag: NO Hello, here is the fifth revision of my patches implementing deferred inode reclaim to deal with MM warnings due to GFP_NOFAIL allocations from reclaim paths. This happens because to reclaim some inodes, filesystems have to do IO including complex operations using journalling and forward progress of these depends on successful memory allocations (which is impossible to guarantee from reclaim context). There is one notable change since v4 - I've dropped the patch implementing protection of deferred inode reclaim from filesystem freezing. The reasons for that are: 1) Inode reclaim can hang on frozen fs now the same way as with deferred inode reclaim. So far nobody complained about kswapd being blocked like that and blocking deferred inode reclaim worker is going to have even lower impact on the system. So this apparently isn't a practical problem today. 2) Such blocking of inode eviction on frozen fs is rare (the only scenario I'm aware of is overlayfs dropping last reference of unlinked inode on lower fs from its ->evict method). 3) Protecting inode deferred inode reclaim from freezing (and blocking on frozen fs) would introduce much more visible stalls in reclaim on frozen fs with possible (userspace) deadlocks when somebody wants to read inode under reclaim back into memory. The patches have survived full fstests run on ext4 when marking all loaded ext4 inodes for deferred reclaim to stress the deferred reclaim paths. I have also tested (when marking all inodes for deferred reclaim) the patches by creating a memcg with 128m memory limit and then scanning from 10 processes 1m inodes in total which heavily exercises deferred inode reclaim paths. This also verified efficiency of throttling of marking of inodes for deferred reclaim. Basically we cannot guarantee any particular limit on the number of inodes queued for deferred reclaim as that is bound only by their number in memory and memory pressure. But as the number of queued inodes grows, the tasks creating them get slowed down so eventually some equilibrium is hit. In my VM this was at ~10k inodes (only slightly above the 8k limit when throttling kicks in) but this all very much depends on the reclaim pressure, speed of deferred reclaim etc. so I don't think this is some representative number. The first patch is a pure fix for a problem I've hit when running fstests, the second patch fixes queueing of inodes with only timestamps dirty into writeback lists. The third patch deals with lazy timestamp updates which I've decided to handle better directly inside the writeback infrastructure instead of deferring reclaim. The remaining patches implement the inode reclaim deferal. Ext4 use of deferred inode reclaim is there mostly as a demonstration. Other filesystems need to determine which inodes need deferred reclaim and mark them as such which generally requires good internal knowledge of the filesystem. I'm hoping that once the infrastructure is there, fs developers prompted by MM warnings will start using it :). I know for a fact that besides ext4 e.g. gfs2 wants to use this infrastructure. Honza Changes since v4: * Fix whitespace damage * Avoid pointless schedule on 0 delays in throttle_inode_deferred_reclaim() * Added fix for redirty_tail_locked() and process_inode_switch_wbs() to move inode to b_dirty_time list of only timestamps are dirty * Waking of workes now takes into account total number of queued inodes, not just the immedialy queued batch so that more workers are woken up for a storm of single-inode additions. * Removed freeze protection of reclaim workers Changes since v3: * Improve logic to expedite writeback of I_DIRTY_TIME inodes to handle also the case when inode is dirty or under writeback * Defer reclaim of I_METADATA_WRITEBACK inodes * Handle kernel workers when throttling deferred inode reclaim * Fix memory leak in throttling code * Fix synchronization between superblock teardown and deferred inode reclaim * Fix synchronization between superblock freezing and deferred inode reclaim Changes since v2: * Some cleanups and simplifications from Andreas Grunbacher * Fixed couple of bugs pointed out by Sashiko * Added support for auto-deferring eviction from iput() when inode has 0 link count and we are in reclaim path * Added protection of deferred reclaim from filesystem freezing * Throttling now doesn't happen directly in mark_inode_reclaim_deferred() but on exit to userspace Changes since v1: * Multiple workers to reclaim deferred inodes, related to that I've moved lists of deferred inodes from per-sb to global ones * Added missed lazytime sync fix Previous versions: Link: http://lore.kernel.org/r/20260429174850.18223-1-jack@suse.cz # v1 Link: http://lore.kernel.org/r/20260911081309.14137-1-jack@suse.cz # v2 Link: http://lore.kernel.org/r/20261009133253.20102-1-jack@suse.cz # v3 Link: http://lore.kernel.org/r/20261124113450.3451-1-jack@suse.cz # v4 Link: http://lore.kernel.org/r/20261201105048.19293-1-jack@suse.cz # v4