From patchwork Tue Apr 15 23:16:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 14052947 Received: from bee.birch.relay.mailchannels.net (bee.birch.relay.mailchannels.net [23.83.209.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9FFF28F532; Tue, 15 Apr 2025 23:32:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.209.14 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744759978; cv=pass; b=V2pQj/niZTNgoEaBnJ+tB63SMj3P/mx5TZiYi1wF0a4NL0aIfNgHHDMJQO62bOLqa5Y/k96dnGaZYmt3GOlFfYQDDiz5g0QLZrdOC1nbRgWdj5eyue7e9SCCLRo0b/AyA+T1mmIObnkbpInIenedgW8h0JzAiaILjZY8YuOe/5Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744759978; c=relaxed/simple; bh=/3d6UuyViHZlf+yrsq8UV8yVwOKcdPWulDarLIeea54=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eKdQRvXGvypr5cJAjFTFHzSJt3S8iaXSqA9gPmObeRyZWBOFj152l+IdUkNwP6ChUdxVwt3ROJrb/MsjacHcT/ZPYpwvB6XPuTylwTZFy57esa9Avc1exgkWW8XShsDlcnJ9uJjarNRqkvqPGB0T/mV3256CW3timLcQ598UovQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net; spf=pass smtp.mailfrom=stgolabs.net; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b=Kj0RJwy1; arc=pass smtp.client-ip=23.83.209.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b="Kj0RJwy1" X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 291318A3920; Tue, 15 Apr 2025 23:16:44 +0000 (UTC) Received: from pdx1-sub0-mail-a273.dreamhost.com (trex-4.trex.outbound.svc.cluster.local [100.109.60.75]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id B953C8A37B9; Tue, 15 Apr 2025 23:16:43 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1744759003; a=rsa-sha256; cv=none; b=E8q9AoP16/bQrOSIysV6vFRwf2hwlPb+gpx4QjTzLDEASMsII0oXTaHaO3DqZj9mPmNMKp pw8gJxmwDRjpxW0q/rSo6uh6LYGcD1BRDbF68uvdpwsWiihAadWaDQpB+SyFlL7UdpwCzG AThbaUjVDbJSr41KXjSm29PZGy4OVin36tST+By4VoGqR+cstQXBc3fBD5Hy/Jrc/bD3h6 3KWZ6InKARWkuAsgE0quf0vX5I/KGkbhHQk8VQSEa5GPHY7WgYEUBszjcyFszRcQkmxA9y h2ny6lSbxlMSAa1ao7On0tvuEVtfcv0mID/pPNRnYzEbV7OizBEGYOIZvJznkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1744759003; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=JHAbDv9/MPvL4PxZXFpm47ZYR2SHKjfrJhea+dpq7dE=; b=XYGWqfuOzpmW1v3Hf4Y1goMr4pfqD+cNF0i+Fdb+jy8k1fG2je4gP7q5FP1i4DGxsmp5b4 3gzxF4bmhrYkm8/6fKkMZzYCkFjkS4AkOe9Az649mqetAxusYJ5GYcZdubDAqAl2bEQumN HDeRXfD+HJrorQsEVKY+3d1sCI7igAGn5xCmrTCjhSe6xez7pCTDPDYnhWlMAJ4dQDPBJt x17zn4QhrME+khADI5WP11eXLx2M5DTaLcqMXosxu3SNA1mrCAhYBZwOPtPNF58mNWFGW5 lBa69SlNKnaI9XfDGPU2zVwDl/VTsobiEWE2lTOKbkEvzx0ndC9lC3DnPlgi9A== ARC-Authentication-Results: i=1; rspamd-5dd7f8b4cd-4m6r4; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Trade-Trouble: 70ffde75512becb1_1744759004055_3358966167 X-MC-Loop-Signature: 1744759004055:1312116752 X-MC-Ingress-Time: 1744759004055 Received: from pdx1-sub0-mail-a273.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.109.60.75 (trex/7.0.3); Tue, 15 Apr 2025 23:16:44 +0000 Received: from localhost.localdomain (ip72-199-50-187.sd.sd.cox.net [72.199.50.187]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a273.dreamhost.com (Postfix) with ESMTPSA id 4Zcg5k6RFrz2Y; Tue, 15 Apr 2025 16:16:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1744759003; bh=JHAbDv9/MPvL4PxZXFpm47ZYR2SHKjfrJhea+dpq7dE=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=Kj0RJwy1xI6A26/9JRzYZ/SPJxCVIPwxFkYWCE+3zKwbTUhV9Min7a+cJxHe3DKjm VHDkCbHhsRggnKKiq6Gelr8UzT+XDZGyeCVmpH8XNH/VvYBusKTWhtaXXNqPFptjjC VpCoVbMglaH7lUEJv581uzd2CIgKZvK13COe2fKcph7iw8guMayFX9i60Fcm0fw6h8 zxSfWdM0oD1y1T5Ia7R4ylOf6/Fh3g5uqBFgqUyUCoTX9m5irIVLo0Ma7Ty0NwBdom 5f+NNPwnwCRnPcTEOTi19doW605M0FLe8nwQumORVXyW/+PH4W2A7i7f7u7BukFOqJ CSuzi8SNSgmIA== From: Davidlohr Bueso To: jack@suse.cz, tytso@mit.edu, adilger.kernel@dilger.ca, brauner@kernel.org Cc: mcgrof@kernel.org, willy@infradead.org, hare@suse.de, djwong@kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Davidlohr Bueso Subject: [PATCH 1/7] fs/buffer: split locking for pagecache lookups Date: Tue, 15 Apr 2025 16:16:29 -0700 Message-Id: <20250415231635.83960-2-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250415231635.83960-1-dave@stgolabs.net> References: <20250415231635.83960-1-dave@stgolabs.net> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Callers of __find_get_block() may or may not allow for blocking semantics, and is currently assumed that it will not. Layout two paths based on this. The the private_lock scheme will continued to be used for atomic contexts. Otherwise take the folio lock instead, which protects the buffers, such as vs migration and try_to_free_buffers(). Per the "hack idea", the latter can alleviate contention on the private_lock for bdev mappings. For reasons of determinism and avoid making bugs hard to reproduce, the trylocking is not attempted. No change in semantics. All lookup users still take the spinlock. Signed-off-by: Davidlohr Bueso Reviewed-by: Jan Kara --- fs/buffer.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index b99dc69dba37..c72ebff1b3f0 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -176,18 +176,8 @@ void end_buffer_write_sync(struct buffer_head *bh, int uptodate) } EXPORT_SYMBOL(end_buffer_write_sync); -/* - * Various filesystems appear to want __find_get_block to be non-blocking. - * But it's the page lock which protects the buffers. To get around this, - * we get exclusion from try_to_free_buffers with the blockdev mapping's - * i_private_lock. - * - * Hack idea: for the blockdev mapping, i_private_lock contention - * may be quite high. This code could TryLock the page, and if that - * succeeds, there is no need to take i_private_lock. - */ static struct buffer_head * -__find_get_block_slow(struct block_device *bdev, sector_t block) +__find_get_block_slow(struct block_device *bdev, sector_t block, bool atomic) { struct address_space *bd_mapping = bdev->bd_mapping; const int blkbits = bd_mapping->host->i_blkbits; @@ -204,7 +194,16 @@ __find_get_block_slow(struct block_device *bdev, sector_t block) if (IS_ERR(folio)) goto out; - spin_lock(&bd_mapping->i_private_lock); + /* + * Folio lock protects the buffers. Callers that cannot block + * will fallback to serializing vs try_to_free_buffers() via + * the i_private_lock. + */ + if (atomic) + spin_lock(&bd_mapping->i_private_lock); + else + folio_lock(folio); + head = folio_buffers(folio); if (!head) goto out_unlock; @@ -236,7 +235,10 @@ __find_get_block_slow(struct block_device *bdev, sector_t block) 1 << blkbits); } out_unlock: - spin_unlock(&bd_mapping->i_private_lock); + if (atomic) + spin_unlock(&bd_mapping->i_private_lock); + else + folio_unlock(folio); folio_put(folio); out: return ret; @@ -1388,14 +1390,15 @@ lookup_bh_lru(struct block_device *bdev, sector_t block, unsigned size) * it in the LRU and mark it as accessed. If it is not present then return * NULL */ -struct buffer_head * -__find_get_block(struct block_device *bdev, sector_t block, unsigned size) +static struct buffer_head * +find_get_block_common(struct block_device *bdev, sector_t block, + unsigned size, bool atomic) { struct buffer_head *bh = lookup_bh_lru(bdev, block, size); if (bh == NULL) { /* __find_get_block_slow will mark the page accessed */ - bh = __find_get_block_slow(bdev, block); + bh = __find_get_block_slow(bdev, block, atomic); if (bh) bh_lru_install(bh); } else @@ -1403,6 +1406,12 @@ __find_get_block(struct block_device *bdev, sector_t block, unsigned size) return bh; } + +struct buffer_head * +__find_get_block(struct block_device *bdev, sector_t block, unsigned size) +{ + return find_get_block_common(bdev, block, size, true); +} EXPORT_SYMBOL(__find_get_block); /** From patchwork Tue Apr 15 23:16:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 14052917 Received: from slategray.cherry.relay.mailchannels.net (slategray.cherry.relay.mailchannels.net [23.83.223.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A5A61C54B2; Tue, 15 Apr 2025 23:16:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.223.169 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744759013; cv=pass; b=FaHdiWg/HsRNb7unB7eDgDvxdO/48DAesIydJziHhWw3NnlZqkPOPt0oMUWET9xrTmqGxYCpNSZNXVwkaGTBEMi7tMGKAsIpDa/cqqxAXrRnPb+sRyUdd7bop40RKgDbL+z1bIRu8lckBkTX8MMScFlXeqaTWmDH5tSb0LC3Rt0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744759013; c=relaxed/simple; bh=vXp+7A6C1prdWk8YUf17h0mCxN/R5WpQdjq+ArmC760=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aQCYGJumdWq2gFv9EhYHWNX4x5qM3wZhv9DBHltQZdmqO9sEMB4Uel5v2tWDNPAPVLzo/viZDaDeDbt7LY3PHumcwh+L0g96jlqfovTyir4CJ9bQTRv0PCW5PC0zghbcynP+G3XSzh66qzHrGY2WXxu2LR55YcxLBoBHsOm49kg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net; spf=pass smtp.mailfrom=stgolabs.net; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b=a+XFqJrr; arc=pass smtp.client-ip=23.83.223.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b="a+XFqJrr" X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 184C34E4E5B; Tue, 15 Apr 2025 23:16:45 +0000 (UTC) Received: from pdx1-sub0-mail-a273.dreamhost.com (100-110-51-113.trex-nlb.outbound.svc.cluster.local [100.110.51.113]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id A5E554E4E16; Tue, 15 Apr 2025 23:16:44 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1744759004; a=rsa-sha256; cv=none; b=NTW3myPlETQscL1J+mXpbDHaHxx6yex13JilGByUZ78pzpOkYH1NNPR3klLH64uo6RuUP9 VTCXwf0n1MSrZOohj9RY1V/alLVay73CasT63x05ijpn9bu8HvO2zQIslTbOJVaeYEBze4 0C+aE4zwxUanjwU4bTJQsKSEWOo8A5ACR6KTtGs02pf3QUWwkPul28R/LHcVnJKNE00lE6 i5ytejpaa4jy5pckwH3rlKcwGVHIDpXSgXFlhtJOTVlbh0HTU/tDKcMRjlbTDM04wd5kp5 C8DGHblVpAx9BomVzl0+sfWGHXHybmC5fRkZUz1FpySIH3BbI81hDzuL2F/i/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1744759004; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7mbzxp8wiNL0OtR9zYzwyCfKKL0JnZdqXEtMAONmpHU=; b=GqG8wqpBNd/6Yf9muaJGH664VPVARwxhH9eBoYu566Z8Bwt/Nq6lgkCH7UkT/imriA7Zwp Rph2/vxCJJmMDycDbSmfyDXDD6c+UhaBwONbG5kaYUMcksc7W+zJPdlIz/mBou2RkhSXQV ZkwVqaGyuttZKvg7nAnKl/r1L5RyDCdFRjIGkOMFbFVOACEduqx3nmMuplflgLZrQLqw+z U7Em4eS2kNMyNHB2xCU7mhkDVR1fuPgA2FFEYtCPR/aJcqG61cvNfw5z+cYasI4366l7VD Z4BShXoDW4AIK3BlfjBPOk/mDZcf/c2KmrdUmqObOQ7w3pAbDDARFjXO1aBc4w== ARC-Authentication-Results: i=1; rspamd-5dd7f8b4cd-qrpj4; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Hook-Fearful: 5407714374c9829c_1744759004996_2600025280 X-MC-Loop-Signature: 1744759004996:3493891324 X-MC-Ingress-Time: 1744759004996 Received: from pdx1-sub0-mail-a273.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.110.51.113 (trex/7.0.3); Tue, 15 Apr 2025 23:16:44 +0000 Received: from localhost.localdomain (ip72-199-50-187.sd.sd.cox.net [72.199.50.187]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a273.dreamhost.com (Postfix) with ESMTPSA id 4Zcg5l5T0Pz8V; Tue, 15 Apr 2025 16:16:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1744759004; bh=7mbzxp8wiNL0OtR9zYzwyCfKKL0JnZdqXEtMAONmpHU=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=a+XFqJrr0fpF77UXqvxgA8PYjmYtGfYME29GQ/RXR4ipjs8xAa+OvvME4pXGxjizt ZHBeqoxZxyT9d3CBdcwHfIv6o/BxmAAKWSMqtm977W6EcylHhIZevCVw+L3LWwwdPf wDYSYCrh/17b4OjWeefNToeg6MiGvJLleRTxKr1kjFpOwUef/bQ0iOQgiV2NTfpwLM LTJ7tsmWjcsMtal46NeBHqqwtGzJgPx4lr7znnU6psFziZ+iPCz18sqNupmYMfwc01 ZXAt5CNr14g6dMvDcrtofjYR+20shnRrMRnmovmqcGwPMOQ5QjuvUWsocS3RS6+eil 2REKCEDscH8HA== From: Davidlohr Bueso To: jack@suse.cz, tytso@mit.edu, adilger.kernel@dilger.ca, brauner@kernel.org Cc: mcgrof@kernel.org, willy@infradead.org, hare@suse.de, djwong@kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Davidlohr Bueso Subject: [PATCH 2/7] fs/buffer: introduce sleeping flavors for pagecache lookups Date: Tue, 15 Apr 2025 16:16:30 -0700 Message-Id: <20250415231635.83960-3-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250415231635.83960-1-dave@stgolabs.net> References: <20250415231635.83960-1-dave@stgolabs.net> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add __find_get_block_nonatomic() and sb_find_get_block_nonatomic() calls for which users will be converted where safe. These versions will take the folio lock instead of the mapping's private_lock. Signed-off-by: Davidlohr Bueso Reviewed-by: Jan Kara --- fs/buffer.c | 9 +++++++++ include/linux/buffer_head.h | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/fs/buffer.c b/fs/buffer.c index c72ebff1b3f0..64034638ee2c 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1414,6 +1414,15 @@ __find_get_block(struct block_device *bdev, sector_t block, unsigned size) } EXPORT_SYMBOL(__find_get_block); +/* same as __find_get_block() but allows sleeping contexts */ +struct buffer_head * +__find_get_block_nonatomic(struct block_device *bdev, sector_t block, + unsigned size) +{ + return find_get_block_common(bdev, block, size, false); +} +EXPORT_SYMBOL(__find_get_block_nonatomic); + /** * bdev_getblk - Get a buffer_head in a block device's buffer cache. * @bdev: The block device. diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index f0a4ad7839b6..c791aa9a08da 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -222,6 +222,8 @@ void __wait_on_buffer(struct buffer_head *); wait_queue_head_t *bh_waitq_head(struct buffer_head *bh); struct buffer_head *__find_get_block(struct block_device *bdev, sector_t block, unsigned size); +struct buffer_head *__find_get_block_nonatomic(struct block_device *bdev, + sector_t block, unsigned size); struct buffer_head *bdev_getblk(struct block_device *bdev, sector_t block, unsigned size, gfp_t gfp); void __brelse(struct buffer_head *); @@ -397,6 +399,12 @@ sb_find_get_block(struct super_block *sb, sector_t block) return __find_get_block(sb->s_bdev, block, sb->s_blocksize); } +static inline struct buffer_head * +sb_find_get_block_nonatomic(struct super_block *sb, sector_t block) +{ + return __find_get_block_nonatomic(sb->s_bdev, block, sb->s_blocksize); +} + static inline void map_bh(struct buffer_head *bh, struct super_block *sb, sector_t block) { From patchwork Tue Apr 15 23:16:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 14053003 Received: from dog.birch.relay.mailchannels.net (dog.birch.relay.mailchannels.net [23.83.209.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0CCE28DD0; Wed, 16 Apr 2025 00:52:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.209.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744764776; cv=pass; b=WonmANqY0VvgAEVvgBe1rbKjVCMYmWsTn14Agmno7JStPseUdmIuwpIUfpKzog7qkRsrPqV6ARkk2/4ysa+vcQvnfgx9pjtkzGUqG86O/msxWNUi8c133ZAlC7RbP/K9SXijFx8e/a4GVjLX08gwyqTrFqT9BC9c2em6TZsVKrQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744764776; c=relaxed/simple; bh=DGEiI0J0IsO72e9mhDRaGawCuz/hLM1g1qEY7AU5G2o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TeaIRmfKizs/3Dltw4IlbGzPR9OkkVZma7txfewIou+Fa5UqAiY876xssI4tXI/P4rzQbayGHwaKRtnm99CPP/0pQLIfDyn6mFvDjyyX6rlrdZjSlp20vTSdSS/CvmCsC7owliZ3KInQEl8/Lo/LeGrUpskmPIlosB5rfuyrKhQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net; spf=pass smtp.mailfrom=stgolabs.net; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b=MNKB93FB; arc=pass smtp.client-ip=23.83.209.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b="MNKB93FB" X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id EC6892C38BA; Tue, 15 Apr 2025 23:16:45 +0000 (UTC) Received: from pdx1-sub0-mail-a273.dreamhost.com (trex-3.trex.outbound.svc.cluster.local [100.110.51.173]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 8BDD52C517B; Tue, 15 Apr 2025 23:16:45 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1744759005; a=rsa-sha256; cv=none; b=A5YBa6qqVAqi5HK1NVPY/z9YeSGUoedGVCD7dfFGlnj7AeQiLeoAkSLi7+WMng8iJXdXo8 9MgbWW8eKxOY71aMmbU2gJbgJL9V4wUmGNx+SBYl/ix74RTk3IEqBVhnfKiz2XyqrFPQYW 7kUHcjEgAmjvxkC8LlZlUEkb7tMEmu77yTyhv3TUfEVeq15nnhYRq0kT8pfs4KmUFd0F9V u8dLsuQudyGqE9sOWAfsRLXPwAxUkywLWf74qO08VdWVuz3s9i6vS+3hgcmmsdYBBcJxAd 3tc/UcCKMBFZUc5Ohe8sZ6iAnty3vM1svFGK2oITDqTUrXJWBkqZCNvXGQz9RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1744759005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uHREBisV1DDhdKY8B6xaTzgB1WkfIIV5PMPRwi7cLCg=; b=dBTIgFrxySGjHVFBz4J+O6wUEUWaH3vGAr86teKCXnIOdw+3OqcDC6a4iA6mtXp5rMADM5 /3NmvOjet25nqcGuOvWouHozYUn9C7XsEBkWsQ5oxJ62EKob2yhbpR4xwJgoyAnaKzeQVR ZXjfZSQLuJ10QPRHJ+YQAQwMslkMNqpHUq6N3nlfkucLu5HzgyaAJA/Z47KG96DBCmMujC uV0flEGYXQTVfjmVi3dAddtsN/bPIZonzO0uHgykSczHcNYzNpFI3YU13i7nnQyCAHKX/V dhQLe2AdT7dC45rKudssmcDs1X80E5gnkG5shMzTB/O3lu2qCT3AotHba7j2aA== ARC-Authentication-Results: i=1; rspamd-5dd7f8b4cd-4m6r4; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Tangy-Irritate: 42ddaa952653b5b1_1744759005864_3471668932 X-MC-Loop-Signature: 1744759005864:1886427043 X-MC-Ingress-Time: 1744759005864 Received: from pdx1-sub0-mail-a273.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.110.51.173 (trex/7.0.3); Tue, 15 Apr 2025 23:16:45 +0000 Received: from localhost.localdomain (ip72-199-50-187.sd.sd.cox.net [72.199.50.187]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a273.dreamhost.com (Postfix) with ESMTPSA id 4Zcg5m52GBz6g; Tue, 15 Apr 2025 16:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1744759005; bh=uHREBisV1DDhdKY8B6xaTzgB1WkfIIV5PMPRwi7cLCg=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=MNKB93FB1rPUY2XJUD/TCQK/S/jnxwGI48Z8zGnQjymdXzKrs0r/t32sKKXfb8umN Ni8fqN3c2Mx16cUOrAMuyhz7EHU+vX3aGbKyEjE++OHM3jVhWHKpfQ0SMEj3idEd2K a6QymDXhWyj8rA3Q9HQKnMQqlX31vYw4e0AkxQ6kq+H6SrGLjO4hNgUqi4vlrs/0Ju 1CukRBbuvmBUA0ww0wv4XLpVbxQut6bOK9wo1YQv8/KQ/XV/jm3ECcqAlhpiPYfy1T c3zvrKYbhFSaIdEzQ7fnUNE2Xth0FWmvyfAFWX7U1+CuR9PA6d5l82QsPHcCRHNXce +sbW4crlsINbg== From: Davidlohr Bueso To: jack@suse.cz, tytso@mit.edu, adilger.kernel@dilger.ca, brauner@kernel.org Cc: mcgrof@kernel.org, willy@infradead.org, hare@suse.de, djwong@kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Davidlohr Bueso Subject: [PATCH 3/7] fs/buffer: use sleeping version of __find_get_block() Date: Tue, 15 Apr 2025 16:16:31 -0700 Message-Id: <20250415231635.83960-4-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250415231635.83960-1-dave@stgolabs.net> References: <20250415231635.83960-1-dave@stgolabs.net> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert to the new nonatomic flavor to benefit from potential performance benefits and adapt in the future vs migration such that semantics are kept. Convert write_boundary_block() which already takes the buffer lock as well as bdev_getblk() depending on the respective gpf flags. There are no changes in semantics. Suggested-by: Jan Kara Signed-off-by: Davidlohr Bueso Reviewed-by: Jan Kara --- fs/buffer.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 2.39.5 diff --git a/fs/buffer.c b/fs/buffer.c index 64034638ee2c..f8e63885604b 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -658,7 +658,9 @@ EXPORT_SYMBOL(generic_buffers_fsync); void write_boundary_block(struct block_device *bdev, sector_t bblock, unsigned blocksize) { - struct buffer_head *bh = __find_get_block(bdev, bblock + 1, blocksize); + struct buffer_head *bh; + + bh = __find_get_block_nonatomic(bdev, bblock + 1, blocksize); if (bh) { if (buffer_dirty(bh)) write_dirty_buffer(bh, 0); @@ -1440,8 +1442,12 @@ EXPORT_SYMBOL(__find_get_block_nonatomic); struct buffer_head *bdev_getblk(struct block_device *bdev, sector_t block, unsigned size, gfp_t gfp) { - struct buffer_head *bh = __find_get_block(bdev, block, size); + struct buffer_head *bh; + + if (gfpflags_allow_blocking(gfp)) + bh = __find_get_block_nonatomic(bdev, block, size); + else + bh = __find_get_block(bdev, block, size); might_alloc(gfp); if (bh) -- From patchwork Tue Apr 15 23:16:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 14052931 Received: from fossa.ash.relay.mailchannels.net (fossa.ash.relay.mailchannels.net [23.83.222.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FF412D8DC0; Tue, 15 Apr 2025 23:22:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.222.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744759377; cv=pass; b=MYD+Evh0JOED39LyP70Z+V36+3VpeH02Rjhz0ufisXGs7P7HmnKxHdTpDZbbfjXnMSCGqLcyQpmjCFLH+harcaOyG4vOUBL6h4mSyIonTE7vX5AD3jvAoxVgQjvoj92py1zvAPsWxerMMYsLML03eF/SkLhwKinkF0/BXFcIGlY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744759377; c=relaxed/simple; bh=5wj7w0EqdqbI4zqcKgQlY4yWeZGmMR0uhyDhMueNQDQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f0pqvVeyBfzS6wHDRVIrlq2tMAqSOFv3tg4SAambSqOIsblzIn9Hn2sEjjI8xU2o9SLK8ZprhPAWAi5CHSuVvRxw/qqhajObj4FYgdS79zx+vEUTxbire5CuG78EgyIYkQ5n0pawtXkcTAJOfNVQbKk/X1SC41LVeLJoGDKjwo8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net; spf=pass smtp.mailfrom=stgolabs.net; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b=gsJGIIgX; arc=pass smtp.client-ip=23.83.222.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b="gsJGIIgX" X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id C64198A4E7A; Tue, 15 Apr 2025 23:16:46 +0000 (UTC) Received: from pdx1-sub0-mail-a273.dreamhost.com (100-110-51-113.trex-nlb.outbound.svc.cluster.local [100.110.51.113]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 640B68A431D; Tue, 15 Apr 2025 23:16:46 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1744759006; a=rsa-sha256; cv=none; b=tUxKOB/9QTR4sBgW0AOL59SVZqDVbUGCYXi/ZdcJbFwCquc60vPyl4v5/MgSjxEfh/s5Xo 37HXyyyr4uSDbbo8dnGHMdZmVqr2cPVqTPlOObuwd/+fyyZCTjsAGyUyAr8l0KDByFYLNi sGdjbwK2gf/F6bUgSEeDaqRIfx9d7a4+NuldmWGmkLCbWz0eEvw4P56VGup+ARujt/Dudh cJ8ohVIwRn6fj+DleN2aJl+hYSjpwelqhB8X0kw2BHfu0jZcCLzOufPIcyOuew47zcLRyi joz1+POFN3uqfHQdvtYN9LwF539i156rDL/io/PFsrwPju556nLJ1lWKHwNciA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1744759006; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=hAfviodp/gLLm0eey766/10wm/tzbxHrlsddbZHBKzc=; b=DGVz1LUHDl9St4pyJy+nI5psn4jN0Ukq2R4MK2jIWDwgYJwkU4MlPB70GpNrOrUIltcCrM p6tRWm59Vcq8cLBDNY7c2WgVpAcRpMuA5+CfYZlKlcvLAfkI9pKS09rj/0wbk6JH4uYxSb jD8T3yEgTUWwaF9WCw/1j6CE3jpWjjxO7mHSZLN47pGc6lsxRF8fWiEBWmVLDfIafG67GK tokttGQntFin8lZLlckrg2JZAIeCD4j6rDKjZuzS3i0J5w8/ywwtW/4+6S7wbqy4mDm0Sc 4knIFtMZ7ffeWCzUABJwVZj75eDRhYEGfj84EsZJxZXjEXusWwcNh4hrk60HKg== ARC-Authentication-Results: i=1; rspamd-5dd7f8b4cd-xblgx; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Share-Reaction: 238d86ac483882e3_1744759006711_2123665616 X-MC-Loop-Signature: 1744759006711:731362905 X-MC-Ingress-Time: 1744759006711 Received: from pdx1-sub0-mail-a273.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.110.51.113 (trex/7.0.3); Tue, 15 Apr 2025 23:16:46 +0000 Received: from localhost.localdomain (ip72-199-50-187.sd.sd.cox.net [72.199.50.187]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a273.dreamhost.com (Postfix) with ESMTPSA id 4Zcg5n4Bmfz2Y; Tue, 15 Apr 2025 16:16:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1744759006; bh=hAfviodp/gLLm0eey766/10wm/tzbxHrlsddbZHBKzc=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=gsJGIIgXbbb+ninDu7ElNLHb2/58AluN4DhLdYyx+nMHoc2XjCeUB+oE7NGHsD+zu KQqWHiDOSuQit0E93orTLPZTrLykpXciu7fgaKDZ77mkGTvK6n0BpKUcEHRGEExwsQ OhepBQJ1/QG/Y0fZYxXqy6OgeBtTX0Q523g4+qqQ1XGkwvvYUMHXkPjxHNf1P4giqz Gi9R+CzUqMaaPnr9FB6UBra6imA5whgp7n6pBTYjfj0FP4jZGSIOwytD/6l6817aJS IdTfubhJIRJ3s8GED/Wo+lgcZGu2rqpyJKpSrKTB24JV551cqRcKVwydMZeI6J4eM4 B5DWhzjypMxuQ== From: Davidlohr Bueso To: jack@suse.cz, tytso@mit.edu, adilger.kernel@dilger.ca, brauner@kernel.org Cc: mcgrof@kernel.org, willy@infradead.org, hare@suse.de, djwong@kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Davidlohr Bueso Subject: [PATCH 4/7] fs/ocfs2: use sleeping version of __find_get_block() Date: Tue, 15 Apr 2025 16:16:32 -0700 Message-Id: <20250415231635.83960-5-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250415231635.83960-1-dave@stgolabs.net> References: <20250415231635.83960-1-dave@stgolabs.net> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This is a path that allows for blocking as it does IO. Convert to the new nonatomic flavor to benefit from potential performance benefits and adapt in the future vs migration such that semantics are kept. Suggested-by: Jan Kara Signed-off-by: Davidlohr Bueso Reviewed-by: Jan Kara --- fs/ocfs2/journal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index f1b4b3e611cb..c7a9729dc9d0 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -1249,7 +1249,7 @@ static int ocfs2_force_read_journal(struct inode *inode) } for (i = 0; i < p_blocks; i++, p_blkno++) { - bh = __find_get_block(osb->sb->s_bdev, p_blkno, + bh = __find_get_block_nonatomic(osb->sb->s_bdev, p_blkno, osb->sb->s_blocksize); /* block not cached. */ if (!bh) From patchwork Tue Apr 15 23:16:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 14052919 Received: from skyblue.cherry.relay.mailchannels.net (skyblue.cherry.relay.mailchannels.net [23.83.223.167]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B41E92D8DA3; Tue, 15 Apr 2025 23:16:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.223.167 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744759016; cv=pass; b=SALHclPLrPIU3i4ayEBXPDJNcWQEV23CjQfCS7LXaNyRTqpfSSrIRjBC22kwsZo+NF/0GfHjnxAqRQaRr99cgAwK5mqLcNKLlQKoZWENbAEwVDEaRlDoaUuI45RRyS6az+QUGEGw/MIKUtXIEMEa9cAqtZ821F1lf3ujQkDmqUg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744759016; c=relaxed/simple; bh=rJm00Lw9MejiGFiVzGyuCU25yiCG19QIA1wZPlFoyg0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UCkmC5DY91t54dcfGvogYkXbOrQzYldEv1o8mJ+3rx63YU/p9ZHhEPY0PcL4/y/c5Q6EOqpH06C+YamwZxHVR1vDVKCmraWMhburvddUNwrwz693Mgfe/N5QN25m7qQUumV3iSsjKdF6nJPXITneztwa5ujuNcfYbAoXiFY3t/g= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net; spf=pass smtp.mailfrom=stgolabs.net; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b=SyQfGtul; arc=pass smtp.client-ip=23.83.223.167 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b="SyQfGtul" X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id A410E1A4F6E; Tue, 15 Apr 2025 23:16:47 +0000 (UTC) Received: from pdx1-sub0-mail-a273.dreamhost.com (trex-9.trex.outbound.svc.cluster.local [100.107.95.94]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 4122D1A4FE0; Tue, 15 Apr 2025 23:16:47 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1744759007; a=rsa-sha256; cv=none; b=ezPCxliX3Neqty+xipVIlcoDe0TzVCgeaBzX6Gta+nfU3iEam/iFJBr3el/Ft9AAzV1jed VDrnSaxoawSTN3DIWxnlpn6ReoBh+cRbBdoxvEuZ/e+FX0HfWH7PTkJmgimGAmYTC7FwxQ 3zHGKiWBF2VorWiVhsjANHi34FKBeY78oV2em43A6oYfR0UY9xytYTCrTJhg2GIULwrNaC qogGTN+k2y9ABVr9YCTn7tHn4O4MP0nZKjEFE1X3XMscV0uRCU8PqtNZEGIKTzlIvSZ4Cd DX59JzTTo9FXbtkRjEEkwpsxjSQqICQ/jc6nJHPArmkBLENmdZlmymDsvcTOjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1744759007; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1l01/oHMrv05TV0ULL7/RgVMZj90KQ8VPfIqNTQ9xYs=; b=7W3dzRToEk+k2/uG5S1+9P/T6IjIX7bxmihfzhkbtfcd99SOobdgQdktOBFf9G/eBi0bQe /lLv4PjThkjPwQ1OYOu7yuIE4fbXc2SbOVn7WHIeQ02vFnOdiE0YfZB2vUV4qd8Ab2gplg WmyvBd6jE3cmC3PFIOW3SGBCHSgD4xGO7YiqxSv01XwkVgzp7g+kME4QVdNgnTvlAREzM0 /wg1qptjsvxa0jtGjZBW+zLYjjO8bWr0aqxs3O+QpgnMpwT+b7X7NMgg5KQTnMGJTruGXp AV3zNYcbGEcJcQlHiD/J14y7IYTV8EzbYJ8xgqH0xkjb0gmBBMZ7jEtLjgTNeg== ARC-Authentication-Results: i=1; rspamd-5dd7f8b4cd-4m6r4; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Reign-Wide-Eyed: 76e12318560162e6_1744759007564_54610796 X-MC-Loop-Signature: 1744759007564:3970048582 X-MC-Ingress-Time: 1744759007564 Received: from pdx1-sub0-mail-a273.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.107.95.94 (trex/7.0.3); Tue, 15 Apr 2025 23:16:47 +0000 Received: from localhost.localdomain (ip72-199-50-187.sd.sd.cox.net [72.199.50.187]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a273.dreamhost.com (Postfix) with ESMTPSA id 4Zcg5p33MRz8V; Tue, 15 Apr 2025 16:16:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1744759007; bh=1l01/oHMrv05TV0ULL7/RgVMZj90KQ8VPfIqNTQ9xYs=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=SyQfGtulaDKy2X3NY8kidDzYIlSRZblPYwswdENl4KWpjYVaXwuels7cffYPH4Bc9 nTST0RjauDvTe2l71YsnwNenD4HkOYxKHsaqZgghQxJLRJuT0evXgJOBZO9T9/JcTf xFB33UBFxwzi0RkdVocWoidHLWnsAJP8vE3Yiezp7DN/upRuUUtjeN2X7uHm5OhoTf dh0C4ikz+GsyVzYGV+DGDex2ZXMOouDeaF9wMYEkzHuPe/HKFbNvlyjQ+20EwVjZBU H2pWGd/9WpjBX12zD/z2yV1TC8z0jNY4/aLYmwzZxAmRizzLrdIu82jd78WDKbDyfH 6KnltscSnjMvw== From: Davidlohr Bueso To: jack@suse.cz, tytso@mit.edu, adilger.kernel@dilger.ca, brauner@kernel.org Cc: mcgrof@kernel.org, willy@infradead.org, hare@suse.de, djwong@kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Davidlohr Bueso Subject: [PATCH 5/7] fs/jbd2: use sleeping version of __find_get_block() Date: Tue, 15 Apr 2025 16:16:33 -0700 Message-Id: <20250415231635.83960-6-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250415231635.83960-1-dave@stgolabs.net> References: <20250415231635.83960-1-dave@stgolabs.net> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert to the new nonatomic flavor to benefit from potential performance benefits and adapt in the future vs migration such that semantics are kept. - jbd2_journal_revoke(): can sleep (has might_sleep() in the beginning) - jbd2_journal_cancel_revoke(): only used from do_get_write_access() and do_get_create_access() which do sleep. So can sleep. - jbd2_clear_buffer_revoked_flags() - only called from journal commit code which sleeps. So can sleep. Suggested-by: Jan Kara Signed-off-by: Davidlohr Bueso Reviewed-by: Jan Kara --- fs/jbd2/revoke.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c index 0cf0fddbee81..1467f6790747 100644 --- a/fs/jbd2/revoke.c +++ b/fs/jbd2/revoke.c @@ -345,7 +345,8 @@ int jbd2_journal_revoke(handle_t *handle, unsigned long long blocknr, bh = bh_in; if (!bh) { - bh = __find_get_block(bdev, blocknr, journal->j_blocksize); + bh = __find_get_block_nonatomic(bdev, blocknr, + journal->j_blocksize); if (bh) BUFFER_TRACE(bh, "found on hash"); } @@ -355,7 +356,8 @@ int jbd2_journal_revoke(handle_t *handle, unsigned long long blocknr, /* If there is a different buffer_head lying around in * memory anywhere... */ - bh2 = __find_get_block(bdev, blocknr, journal->j_blocksize); + bh2 = __find_get_block_nonatomic(bdev, blocknr, + journal->j_blocksize); if (bh2) { /* ... and it has RevokeValid status... */ if (bh2 != bh && buffer_revokevalid(bh2)) @@ -464,7 +466,8 @@ void jbd2_journal_cancel_revoke(handle_t *handle, struct journal_head *jh) * state machine will get very upset later on. */ if (need_cancel) { struct buffer_head *bh2; - bh2 = __find_get_block(bh->b_bdev, bh->b_blocknr, bh->b_size); + bh2 = __find_get_block_nonatomic(bh->b_bdev, bh->b_blocknr, + bh->b_size); if (bh2) { if (bh2 != bh) clear_buffer_revoked(bh2); @@ -492,9 +495,9 @@ void jbd2_clear_buffer_revoked_flags(journal_t *journal) struct jbd2_revoke_record_s *record; struct buffer_head *bh; record = (struct jbd2_revoke_record_s *)list_entry; - bh = __find_get_block(journal->j_fs_dev, - record->blocknr, - journal->j_blocksize); + bh = __find_get_block_nonatomic(journal->j_fs_dev, + record->blocknr, + journal->j_blocksize); if (bh) { clear_buffer_revoked(bh); __brelse(bh); From patchwork Tue Apr 15 23:16:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 14052918 Received: from bumble.maple.relay.mailchannels.net (bumble.maple.relay.mailchannels.net [23.83.214.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CBE91C54B2; Tue, 15 Apr 2025 23:16:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.214.25 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744759016; cv=pass; b=jlPqcWOC1c8OrJd8PyPxPCVASOibdKXJc6V/q/GoPC1aIBVsUpzTc3Nw0zRrwptnVq3kxBmwEysSQevLYPp2GmsIjEQtj1vNPOl+G7952MYOszVrrMpX4Giyr2fX81qzxDGIr1RXYzV7DCnifgYhzhjTZ/bW3aePPmzxlWZOiE4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744759016; c=relaxed/simple; bh=5J3ljwPyF1mfwRP7vhzDB2o1aUde7xmI5aCYQrijMjQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aY6wfDBRE4adrFPWmh3ai89pitclLPIl/5Nk7RJc8MjavSQefMetaYkAopAW0v1gZvyn3plZLiq44Hn5aApHwsjeOo2BnnWiXpzeFPB/M983nzOtgz8pzO6OA3tbOQPgaqmricAWibaDBDT82L913B5voozsRbdPtupH/CcoYAE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net; spf=pass smtp.mailfrom=stgolabs.net; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b=pg09XEWF; arc=pass smtp.client-ip=23.83.214.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b="pg09XEWF" X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 7EF532C5169; Tue, 15 Apr 2025 23:16:48 +0000 (UTC) Received: from pdx1-sub0-mail-a273.dreamhost.com (100-109-60-75.trex-nlb.outbound.svc.cluster.local [100.109.60.75]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 1AFCA2C5171; Tue, 15 Apr 2025 23:16:48 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1744759008; a=rsa-sha256; cv=none; b=clEznkgPy+EiYjqUnRdlPY8Xp256oAtxLK8cc6A+4Gm0epRB7VXUfT7ExZGEN77rddkfpL e0bl49d7HoXQON5YjRd6det+et3bFtNO2oigtM0yRuu5IwLfEU9gYhtYrcdzfaV9Q3uvF8 9I3D6+u+VzZuHvbq2PXTYnvrOQXVsCYCF/HuFTa3bqHP+Q9NdEgX2tn0d9sUUmFl4/mEnW VXtgXvRQK+kCoaz2rMnLQkfJVcKiyHkbwgWX43W1hkg/RehTG6ZRBzHn5eeI14GOQ3+kYP EMl8S6uqzmsZ6Xl0cWOwY1E9fXMnJY6fz7czshQxgFpbhgXCBY+Cgpb/tpINQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1744759008; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6FfTau9BvNuszvB4UDUEdiDHpoFoAKapXPdYyQlxMQo=; b=nURM1QbZ8resQiKJZ/eyNe7DaQHlU3vRHyL+780WHcnXyDRCbixiPFP16n6TH0NhroRl1D xPpvLcNj3xrkRYbRF5ZcrQkgcllEchx6ElHLL4F+W8pqaOyGYSFqRw3J7PihrHE3M8xkOB 0OHAr+jP85LNrDg9+WvH7KNr+XAg7BO0d9eqgrgCy3N+u9Sy2wWBva6EZramdT5R0C8Yq/ vjRkiG3pzzJg3zuoCRcU6Iji6lFWh8YQq4Lc4aqFgI+QqZ7p/nGUpBGiKa5YA3/44Ji4w5 1LO7RSsVHEYHeJ4NKRhJinCQoPclOXybu4Ogx2A3QlPMRS+1YavkncfEcOpVgQ== ARC-Authentication-Results: i=1; rspamd-5dd7f8b4cd-xblgx; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Decisive-Whimsical: 522e76535dc1ed42_1744759008414_2568278399 X-MC-Loop-Signature: 1744759008414:2054462833 X-MC-Ingress-Time: 1744759008414 Received: from pdx1-sub0-mail-a273.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.109.60.75 (trex/7.0.3); Tue, 15 Apr 2025 23:16:48 +0000 Received: from localhost.localdomain (ip72-199-50-187.sd.sd.cox.net [72.199.50.187]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a273.dreamhost.com (Postfix) with ESMTPSA id 4Zcg5q22wGz2Y; Tue, 15 Apr 2025 16:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1744759008; bh=6FfTau9BvNuszvB4UDUEdiDHpoFoAKapXPdYyQlxMQo=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=pg09XEWFvL3hZNxtY/VDXfDL5ZCooaIA8HYiDt/u/3oux4VT9K+jFGKbHmVcjzcPd grF69IcAdvJuY6lGH3U4/s2hAcRJmU4emU7ho9eAladkVMV0mPpiMQ8uR5VIcXeGhJ vbbiGvxCYpow72dtTdU44yfi998QZ3/xlVXJc+E2IaMPjqFmeyCfoXEL7K48GQTKXL pSLU0TMODhtWFMf3XokCIOdycNz68Q8+R1xTT/xebpBQXzL6DsqHIS0qi0JruhBBpq btnXHvFG5Gwle0+0tiyXuey0J8Wuxvx9iYVTA9cX59YKm57EnrjLMlceY6qH6Jozp8 338AqUh01jPjg== From: Davidlohr Bueso To: jack@suse.cz, tytso@mit.edu, adilger.kernel@dilger.ca, brauner@kernel.org Cc: mcgrof@kernel.org, willy@infradead.org, hare@suse.de, djwong@kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Davidlohr Bueso Subject: [PATCH 6/7] fs/ext4: use sleeping version of sb_find_get_block() Date: Tue, 15 Apr 2025 16:16:34 -0700 Message-Id: <20250415231635.83960-7-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250415231635.83960-1-dave@stgolabs.net> References: <20250415231635.83960-1-dave@stgolabs.net> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Enable ext4_free_blocks() to use it, which has a cond_resched to begin with. Convert to the new nonatomic flavor to benefit from potential performance benefits and adapt in the future vs migration such that semantics are kept. Suggested-by: Jan Kara Signed-off-by: Davidlohr Bueso Reviewed-by: Jan Kara --- fs/ext4/mballoc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index f88424c28194..1e98c5be4e0a 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -6642,7 +6642,8 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, for (i = 0; i < count; i++) { cond_resched(); if (is_metadata) - bh = sb_find_get_block(inode->i_sb, block + i); + bh = sb_find_get_block_nonatomic(inode->i_sb, + block + i); ext4_forget(handle, is_metadata, inode, bh, block + i); } } From patchwork Tue Apr 15 23:16:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 14052946 Received: from poodle.tulip.relay.mailchannels.net (poodle.tulip.relay.mailchannels.net [23.83.218.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCD3928F532; Tue, 15 Apr 2025 23:32:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.218.249 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744759975; cv=pass; b=S/iqtaNK7881H1CcOD4Pg9bKhSAwv7kA4Up3GA+ijHBTfdp/EqBU+f34hPj6QK3eEf5NJe0+xR9N4RIp6sk6jvXmB1BD5FzQ085+6AN0LRmJNZ3U0G3/e2NwXFUZO0cl2GD33pWoTFklCxUR3x2boZEgmxiuCFH2ptmn+cibHPA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744759975; c=relaxed/simple; bh=dShK0AUJCpQQ7rzwY5YV2P4tffllkNK38aHi61tgYB8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C4LPCfy3XgjVHdE8cp2T05pZK8Kd34jleXoDf2J4+RUosV2qsUm1D4V5vamGRqFP7+OI/wMzxLxsXKVrQuexVToON5SEtWA7UtxqBxZDCgQQyRy57SnUO+chz/nhzyqeachjrDf73Em62/36ONjcMzQ3hLF549nQXApw2+fXNQI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net; spf=pass smtp.mailfrom=stgolabs.net; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b=pdkeFYN+; arc=pass smtp.client-ip=23.83.218.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b="pdkeFYN+" X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 8D86C844C70; Tue, 15 Apr 2025 23:16:49 +0000 (UTC) Received: from pdx1-sub0-mail-a273.dreamhost.com (trex-3.trex.outbound.svc.cluster.local [100.110.51.173]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 145DA844C93; Tue, 15 Apr 2025 23:16:49 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1744759009; a=rsa-sha256; cv=none; b=BhEJiJtFvkCwq8VAse19aBQiUxhkx3I+5R6HPsmqZf4e7aKwSiPPW986q2HE3kFNsRKNN+ CdfsNyJflEjavG33gCOm3aagchhCTRZDQsmsYDhQrVrS3YDc3D83CH8qXnfSqlJSWEFCwQ BAuiAebIKU36eG4L/2+jS4bFiSL6ap7/RY0lfPzATrkk+gG//gk2eCRvwHz/bvKAeUwy2O LztYFVMd88BfEaCPwhNC4l8tpMfN6HArgsnllkMyrgGuyaavWLatDR/edgfuhVMiictH0v HeefL/cKCyEyHtfkDDuAXLn2s6+YQU6DIBe1TIvPlvL9ViasagE8gE5uCYkpeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1744759009; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cZxBayk/19ttKico+tYOcz6z5i5bd/KpteFdnFTioS4=; b=pwDyEFNKwZLvyNhomSgsA6Ch2JWc8J52qbKwVcFPj0Y6P7DTPH4++Hmj2H6BB/PL6KlNkN LzWPKmCveLupB2BZIPV6pfrWXrL1r3bW8ZJw43YHHLOtUCKKcGZLakiXg7C0B1fxMErIzW ifiBIjuHPfQIKiYdMcclddyU+UxOfndgfY4ZyGCOKUoIF9F+5GA7Y0Yv7uAeFGzt3tjPXl jCSz4lr6R8Y8Oqn6eNJOzJZXVa7GtBVpqV9vSxeCe6IotUVyiK/okDPirc1haqWpudz+F6 uqr1nVUCThwP4SDd+8+zflSksqc9IalFfqyCUMIN6j9NXJje2i7q2LNAV7x+0A== ARC-Authentication-Results: i=1; rspamd-5dd7f8b4cd-qrpj4; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Abaft-Madly: 0f7b40494fe41933_1744759009477_58974177 X-MC-Loop-Signature: 1744759009477:425026726 X-MC-Ingress-Time: 1744759009477 Received: from pdx1-sub0-mail-a273.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.110.51.173 (trex/7.0.3); Tue, 15 Apr 2025 23:16:49 +0000 Received: from localhost.localdomain (ip72-199-50-187.sd.sd.cox.net [72.199.50.187]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a273.dreamhost.com (Postfix) with ESMTPSA id 4Zcg5r0xWMz6g; Tue, 15 Apr 2025 16:16:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1744759008; bh=cZxBayk/19ttKico+tYOcz6z5i5bd/KpteFdnFTioS4=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=pdkeFYN+hvN6eTdJcNTCB0qKBgYHTg9M+wgnCHctw021Kq4TJBluwwznOkT4fiuae GioaEn1QRUFTyxxL9XY3Zj0XBm3PRV1Pm7rA+ilF/HBh6CP6lPiBPzOUkxXS1lA5iQ XCJgOHetlIP/kzdCjG5saON6RQClPMhB2BtsKBTwB6lsVAsqwhOq8297Sqc+kcQqwX VMNC4PQ2Eu+LJmiD//KZvW4/343ykgSTNa6QsEr0HI/YfOm5HitgLPdjITEbRGYsPE /aHt8eiK7FnTF0eOS6rGtlz2tQXeHNp0v3wVfnnolphExHswtWkYeQUEP+SG/puId5 60/AllAEwQfww== From: Davidlohr Bueso To: jack@suse.cz, tytso@mit.edu, adilger.kernel@dilger.ca, brauner@kernel.org Cc: mcgrof@kernel.org, willy@infradead.org, hare@suse.de, djwong@kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Davidlohr Bueso , kernel test robot , syzbot+f3c6fda1297c748a7076@syzkaller.appspotmail.com Subject: [PATCH 7/7] mm/migrate: fix sleep in atomic for large folios and buffer heads Date: Tue, 15 Apr 2025 16:16:35 -0700 Message-Id: <20250415231635.83960-8-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250415231635.83960-1-dave@stgolabs.net> References: <20250415231635.83960-1-dave@stgolabs.net> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The large folio + buffer head noref migration scenarios are being naughty and blocking while holding a spinlock. As a consequence of the pagecache lookup path taking the folio lock this serializes against migration paths, so they can wait for each other. For the private_lock atomic case, a new BH_Migrate flag is introduced which enables the lookup to bail. This allows the critical region of the private_lock on the migration path to be reduced to the way it was before ebdf4de5642fb6 ("mm: migrate: fix reference check race between __find_get_block() and migration"), that is covering the count checks. The scope is always noref migration. Reported-by: kernel test robot Reported-by: syzbot+f3c6fda1297c748a7076@syzkaller.appspotmail.com Closes: https://lore.kernel.org/oe-lkp/202503101536.27099c77-lkp@intel.com Fixes: 3c20917120ce61 ("block/bdev: enable large folio support for large logical block sizes") Co-developed-by: Luis Chamberlain Signed-off-by: Davidlohr Bueso Reviewed-by: Jan Kara --- fs/buffer.c | 12 +++++++++++- fs/ext4/ialloc.c | 3 ++- include/linux/buffer_head.h | 1 + mm/migrate.c | 8 +++++--- 4 files changed, 19 insertions(+), 5 deletions(-) 2.39.5 diff --git a/fs/buffer.c b/fs/buffer.c index f8e63885604b..b8e1e6e325cd 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -207,6 +207,15 @@ __find_get_block_slow(struct block_device *bdev, sector_t block, bool atomic) head = folio_buffers(folio); if (!head) goto out_unlock; + /* + * Upon a noref migration, the folio lock serializes here; + * otherwise bail. + */ + if (test_bit_acquire(BH_Migrate, &head->b_state)) { + WARN_ON(!atomic); + goto out_unlock; + } + bh = head; do { if (!buffer_mapped(bh)) @@ -1390,7 +1399,8 @@ lookup_bh_lru(struct block_device *bdev, sector_t block, unsigned size) /* * Perform a pagecache lookup for the matching buffer. If it's there, refresh * it in the LRU and mark it as accessed. If it is not present then return - * NULL + * NULL. Atomic context callers may also return NULL if the buffer is being + * migrated; similarly the page is not marked accessed either. */ static struct buffer_head * find_get_block_common(struct block_device *bdev, sector_t block, diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 38bc8d74f4cc..e7ecc7c8a729 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -691,7 +691,8 @@ static int recently_deleted(struct super_block *sb, ext4_group_t group, int ino) if (!bh || !buffer_uptodate(bh)) /* * If the block is not in the buffer cache, then it - * must have been written out. + * must have been written out, or, most unlikely, is + * being migrated - false failure should be OK here. */ goto out; diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index c791aa9a08da..0029ff880e27 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -34,6 +34,7 @@ enum bh_state_bits { BH_Meta, /* Buffer contains metadata */ BH_Prio, /* Buffer should be submitted with REQ_PRIO */ BH_Defer_Completion, /* Defer AIO completion to workqueue */ + BH_Migrate, /* Buffer is being migrated (norefs) */ BH_PrivateStart,/* not a state bit, but the first bit available * for private allocation by other entities diff --git a/mm/migrate.c b/mm/migrate.c index 6e2488e5dbe4..c80591514e66 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -845,9 +845,11 @@ static int __buffer_migrate_folio(struct address_space *mapping, return -EAGAIN; if (check_refs) { - bool busy; + bool busy, migrating; bool invalidated = false; + migrating = test_and_set_bit_lock(BH_Migrate, &head->b_state); + VM_WARN_ON_ONCE(migrating); recheck_buffers: busy = false; spin_lock(&mapping->i_private_lock); @@ -859,12 +861,12 @@ static int __buffer_migrate_folio(struct address_space *mapping, } bh = bh->b_this_page; } while (bh != head); + spin_unlock(&mapping->i_private_lock); if (busy) { if (invalidated) { rc = -EAGAIN; goto unlock_buffers; } - spin_unlock(&mapping->i_private_lock); invalidate_bh_lrus(); invalidated = true; goto recheck_buffers; @@ -883,8 +885,7 @@ static int __buffer_migrate_folio(struct address_space *mapping, unlock_buffers: if (check_refs) - spin_unlock(&mapping->i_private_lock); + clear_bit_unlock(BH_Migrate, &head->b_state); bh = head; do { unlock_buffer(bh); --