From patchwork Fri Apr 18 01:59:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 14056558 Received: from black.elm.relay.mailchannels.net (black.elm.relay.mailchannels.net [23.83.212.19]) (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 A958F267383; Fri, 18 Apr 2025 02:08:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.212.19 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744942099; cv=pass; b=RCF1s6Jf4GJvxo+o9rtEv+hjaHQRSDtX2ykjnG9jAEn5f13Lhh01+icRFTr55EIbjRZCi2F0l+AYoGfu7kfhFElECVieiaxTNPfhJ30LtrO/z/7WaTLSriF+rbkLma/tA9CI4BeYYo+eSFZCIWJC2DNl6AAlrld7IZPUJLE72ow= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744942099; c=relaxed/simple; bh=qFVUR1E/2/5PQt69+ghAsaDqdOPGz0m4+DMcpcnOe4w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VvR85Gego7mTDQpN6CopOCA2W+JCUqv6zUrFeeZI8au8duIpJy/PNexzTzGgSiIz7SWOmEFwfdN6Ogr6ShBGumJT+OKrxyQggAv7tCQolINgfx2qX0TKSgVIBpTaCCtC4FRCb4NYhTR8NKl2/ObYBs7ALVAgpKTzM12WkzNPjW4= 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=p1xyuGdf; arc=pass smtp.client-ip=23.83.212.19 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="p1xyuGdf" 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 DA7C04E3E21; Fri, 18 Apr 2025 01:59:34 +0000 (UTC) Received: from pdx1-sub0-mail-a285.dreamhost.com (100-107-95-229.trex-nlb.outbound.svc.cluster.local [100.107.95.229]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 76E904E3C8C; Fri, 18 Apr 2025 01:59:34 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1744941574; a=rsa-sha256; cv=none; b=nTINgWWCpNRS6h4rQ+hDdWix5ieHLh2YvkU/HGmrRHhrLXnmmFZYLGoAKqREEQLf6NlqEo IzGtcgb2AnszYccBiRaabLwBIwo7+lMSPD3JJ5wICmwx/PiSzTOuJ+5o4y51QKPJuAJpkX KKIZXiOJwxomBWoCnIbE9vXkCbEElRWRtxp9iAhedw/AtxYHXrFD3P8ChDcfUVXY/gZU06 kQj0eWMmb2Ziic72MAVTxz1tOeT6r4jhxkFEa/LNf11beexjbvymPWznMDidxHEb3vcAlm AQKslS6e9CGQIS2daqtl5icWh5OFYhmfhYgRXpoflG0yiZTpA/Vi35hA7hrMBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1744941574; 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=l0OkMrrCNfiNSUNqllJ63trdw8uvDJBD9sB7Chep1qQ=; b=4D5orQYmCxpExXLwDca3eoowuwJ5J7hePJCnS6NJ7850Xdly79QCPLRnrjnpcQo8i+RAFw OoMYQQUncr+AJoKJvYGbQmClNFpFF4ZRwe3qJ1GEzg7HWtFu2x133WRCWQwsgTLQ9hECGy 3XyoweS1nFZbrx4O1vtDjBOfalspQ/FkZ6GuFv35y22WCHvmEN9m9JlQL/uX7FndLspiRO XjjYrgIZF9n9eq3iP3bPXe8Z1LJil829bqpCxwTrHD1vRBcibyx2Bc/PkHOH1twekBw3NF /6K0m97KKSmHZvSxArWSieBCHyoG2CsQlb7SaYIpJluIPoPCxSItWlFZ4meL+w== ARC-Authentication-Results: i=1; rspamd-7bd9ff6c58-mj7hx; 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-Broad-White: 7d820e6c16f23b4a_1744941574795_2082964327 X-MC-Loop-Signature: 1744941574795:136927829 X-MC-Ingress-Time: 1744941574795 Received: from pdx1-sub0-mail-a285.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.107.95.229 (trex/7.0.3); Fri, 18 Apr 2025 01:59:34 +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-a285.dreamhost.com (Postfix) with ESMTPSA id 4Zdycj3m31zC4; Thu, 17 Apr 2025 18:59:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1744941574; bh=l0OkMrrCNfiNSUNqllJ63trdw8uvDJBD9sB7Chep1qQ=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=p1xyuGdfjY+kIZiUDVQxbDoSeumqeD6CRGZS5xt8zFdXGLyWeymMlwNP2bcj49nSW SRsKRijsknB7yuhD91VoidYVvK5Pd4U3BBlR6uxo1nLW76h+jtKoK2j9kJsZlRIqXU QnjWjkTfEWWLLTIQyz9nMXvH6bDSgkKDTT85dGUeAb9SPZ3D49XBTWYQnuSWyCwr1N oaUKT6pKiNEliKnxRCD2Mdc7nnhNcM/aA3L8ETWJpgAnN3cbSfNddVgxTMqPbNdOpz Glib8yBke2/A1WzVVrmTlaUBvp7vEgQ5gCvGpoIy9wfqFonA3uxgDH0RfC2B1ETaKE q96Ib+xiJLoHw== 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: Thu, 17 Apr 2025 18:59:15 -0700 Message-Id: <20250418015921.132400-2-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250418015921.132400-1-dave@stgolabs.net> References: <20250418015921.132400-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. Reviewed-by: Jan Kara Signed-off-by: Davidlohr Bueso --- fs/buffer.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index c7abb4a029dc..f8fcffdbe5d9 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 Fri Apr 18 01:59:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 14056560 Received: from serval.cherry.relay.mailchannels.net (serval.cherry.relay.mailchannels.net [23.83.223.163]) (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 A3CAC17C219; Fri, 18 Apr 2025 02:18:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.223.163 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744942694; cv=pass; b=jaccyuMVLT8rYtQa1vdMoWM2BAT2lOeinV+zRrwQOf39KYI7KQRjh4FOoELtst6l3oB4xhdrKUOARU6FrhnP2m0iYmyk31NuxoO0OaQn3lJWgD2+tAzSDknLfA8WRfeler/jXESKfp2HqM/rcCH4fvayTWeTavFrKYM90mHufR0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744942694; c=relaxed/simple; bh=jyXbNiWiNzC1XA8NQAfHnyWbLLVvpyxgxF7Bk5HV70Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CiTZXGVcOHPRV+qtOe/LJ/sUys5K3Uw7KjrqEoC6EPfONwLL1PI01si0Sg5f66+n5o0I+QmEOovKjFmWDpaNPUpVQ4okvFHFKNO2qCN+zHiDyF3KLpVmrhI0mUKQx/CoVhFRlgTk2arTfQTGxjMfkuYmb59FIE6f6mHdjO5T3p0= 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=rVMv6hky; arc=pass smtp.client-ip=23.83.223.163 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="rVMv6hky" 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 8B71B161484; Fri, 18 Apr 2025 01:59:35 +0000 (UTC) Received: from pdx1-sub0-mail-a285.dreamhost.com (100-110-156-188.trex-nlb.outbound.svc.cluster.local [100.110.156.188]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 2CB7C160603; Fri, 18 Apr 2025 01:59:35 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1744941575; a=rsa-sha256; cv=none; b=XEJ9RA6KXmvwd8Gv0JYxXK/2m8CMqF+ePjPwTGMLUzMz0j6HKa6IZd8kFeqWHU2tGSs3ZB OhvDqJenIZ1AiPf2Vpk91oIYz+LuLvgwnpI+p5Lob7HJm4s1LlvD3DYnwKVJrXI5f6e0N9 4bqRKKdAS/3rNFsCU7t+5fJujJrfhpqEdVL3xsxLd+3TJvegZsKU2Xy7o0OIUN6R4e5Xjd L7auihzUfaC1haRiHhXxljcIp8ff5nFsezK2xWys/pVzNAJgmDnxsGNq7Q7drDgKHqZGBc U5oOdELnHT26Nw8JNCYOlLW8TaViw2+7hOYCMchBwH8X6IycAChP+oxmIsjiLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1744941575; 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=QC8hcWca1VUOV1taXWQ6Z+juBzwnD0z3CPqsdXKoeHc=; b=QtTD6whjx7vCKobg2CP6G6o4rVJjrcemVTTLgOmR5LP764Uq9Dz5ypB8gPh3GPt1sDu1Ym mb4vv4HctY5noKB9S8WQ037BQwF60dxU5wfDJmSug+ntW4+jxVCwKGOmLLsJ9NXBlugzWE 3z3AIT+pWXuGza29hY9IXr+Nq19voXucVh8XWdkfNRTBHNmtNcMOw/58fWgWkqFpUbn7Hy sENDMMQJqFOBoQYsRox5xbMhf8eHDlvNHxVee57ho7n3Pcrz7mvpOUhHhquphUNn9SXK4c luMhp06KyTZyzVuh3eztZxtF4UAOJQyWp66EwRmPHWVIUX0LshayfGPtl/UzUg== ARC-Authentication-Results: i=1; rspamd-7bd9ff6c58-mgflk; 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-Army: 3982c68142220f2a_1744941575469_4289484740 X-MC-Loop-Signature: 1744941575469:2260933014 X-MC-Ingress-Time: 1744941575469 Received: from pdx1-sub0-mail-a285.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.110.156.188 (trex/7.0.3); Fri, 18 Apr 2025 01:59:35 +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-a285.dreamhost.com (Postfix) with ESMTPSA id 4Zdyck2WMxzGH; Thu, 17 Apr 2025 18:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1744941575; bh=QC8hcWca1VUOV1taXWQ6Z+juBzwnD0z3CPqsdXKoeHc=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=rVMv6hkyQa8fjuM+QBSGVYfPcfqeaqnpMwAxt9TghL4tIonvCkNMrl3airJqMqno/ wHLVbaSLotbWqcLsLKDL/mKjWoqAZlXuDgrKX+V5PE+9p0ikWFnCVhdhlcljyjSa6n cUD48qMK7+cl7r9xVOVJu8JCcigSk43mJM5KRnmYSlX8nOoPyhInwuEF/mUklsEVSR I8atEIoU7HMJ5tRNS27jOvaQSBTugEYp2CydV1eGPgAIMYho8wPgjuOpwgW4lTnj3g gSFU75/nvsKqRJVjMAYbbxtI6oaiAQ3zSIrR/zcD0qJg/Dbc3jCt2GCobDHWWdl3o/ wVOMZDjdFOhlg== 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: Thu, 17 Apr 2025 18:59:16 -0700 Message-Id: <20250418015921.132400-3-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250418015921.132400-1-dave@stgolabs.net> References: <20250418015921.132400-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. Reviewed-by: Jan Kara Signed-off-by: Davidlohr Bueso --- 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 f8fcffdbe5d9..5b1d74c818e9 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 Fri Apr 18 01:59:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 14056535 Received: from serval.cherry.relay.mailchannels.net (serval.cherry.relay.mailchannels.net [23.83.223.163]) (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 B1CA2263C66; Fri, 18 Apr 2025 01:59:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.223.163 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744941584; cv=pass; b=FC4MBm/+Sibj8Rf2ZFuKtw9aTXeR/8HdWTxnhQ2V9744ivCrVf3re1AlwzrLfkATEuD3SBwwueY3cddVhLeSSiT2U+xs54kcyIwiCCTbZebfvb75JgWCJG6C6Pk7IAB365sUYCwRJnbRhHwWt8h1XjLf4fADaM0pYPIfmV+rmbE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744941584; c=relaxed/simple; bh=S0+7Sbp02f2x/zYvgMPtdn1xflbBZmWVS7lYOfPOXUE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=U3Xeug8eOcw0S7mOUbQr5/8FTKzL5Xu8IpopmGA+OQqin1POzjOIxs31OwM7rD1+jd9p/aaJJrcoY200AOz673aN2r0FsbwygedjGlObRBTJz9Hk+gnBln6BUnbh99eC+0Pp6qEjqKY0uUDkmuwwRqGFUE3CxO0SfSZP7tfXdVo= 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=YmZSGrjf; arc=pass smtp.client-ip=23.83.223.163 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="YmZSGrjf" 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 8A71A23E1A; Fri, 18 Apr 2025 01:59:36 +0000 (UTC) Received: from pdx1-sub0-mail-a285.dreamhost.com (trex-5.trex.outbound.svc.cluster.local [100.109.60.146]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 2881523B7E; Fri, 18 Apr 2025 01:59:36 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1744941576; a=rsa-sha256; cv=none; b=1224Yog9/g03yVNhDlBDFE/0Hyk/B+JrQKgz/ZPtCgcOUSw/CDV9MtexRW+868b5zjgUnM LTy3XSH61CYUMb6WQgg/Ke/nK/brvI6waRmxiPrN2S+qxqYJ7XhR9d13TYR0uGkoZHLy1z nsUOnxbMdwB4WCz8TvWa6BFsZbJmHqy1oU+CblYsybcfuJNWUHr8OqssZM640C9jb4Q35T ND/b1mVgBCtUMUJsebMmE+QMdHp2pu6MOdA2+LgG/ywhBz/0UqkS+r7Dys11cz+5xdoK/B WrE/GVW2E/K/CtguVgs4su7zIlgOme1vg0yh6t4lS3Z4SvZ46fhukyjHHC/SBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1744941576; 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=2JaAMscrug2FGAwbGl/h9oMw0eHDwe8tdi8SwLuHRGw=; b=o5TA7zJDtpQNfp3RWNv6hV+kzTVIzZ3isMynpiA9NlPpklblcMKBuPikKvukbMff4URwST zg9qS588GrYl699Y76HKHmZP9kOrfLSD2rw5Y9mb/Xkgr2y6gnGGsclFCrX4/pM4RMZ1Yo pEGWEGiA4V4svtGzAkzRrPfAJF6uvdB15E1zS0Yq+KsFGfAKjkMmE92qGt0BFD6PGsjjap +4QHFXaiC0dLH81KAEycwUPl3mTA2j5GcnslSPCc2ylVVS4GyRTFkwOOEAApyQ2io2qoyr WsasbZDgCD3q7wb2N/H5cPWLVggrPMwYq+VWJFBh+h7T6jz7G0x5vauhT5BQ5g== ARC-Authentication-Results: i=1; rspamd-7bd9ff6c58-dhqhn; 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-Cold-Relation: 6c61228447797287_1744941576475_1157459792 X-MC-Loop-Signature: 1744941576475:204546122 X-MC-Ingress-Time: 1744941576475 Received: from pdx1-sub0-mail-a285.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.109.60.146 (trex/7.0.3); Fri, 18 Apr 2025 01:59:36 +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-a285.dreamhost.com (Postfix) with ESMTPSA id 4Zdycl1Nlyz88; Thu, 17 Apr 2025 18:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1744941576; bh=2JaAMscrug2FGAwbGl/h9oMw0eHDwe8tdi8SwLuHRGw=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=YmZSGrjf8jPt/J19BQv5GZPl1g28pGIvNWKqy1j2sTGEvEThhx8B0MQ6bS284Eocs lkjvhxkqZvzRRhhAGLzDpvMrnzoP/QYj2VKErCD3BP4+uSkgVOdYTPNGP8S5BaKFhy ZNMI3GagZT3WXe5OXJvBeuW9pFZ1Idq/0s4wbguLzmKNFBDOsheQ/OMY69y4Xvj6nZ 1tuAvkf4YyroDuSAy23vswcxVMCWCX/x2f1ImKImmi5HNpZ390WS9jAZG8uujheG1s qyyyyIXUGkBHGbPsAUvP58/87KZDesCzyAnOfXbwnrzgAXyFY4274gkHTOQG2k4eWm h3V1Cf52hOC2Q== 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: Thu, 17 Apr 2025 18:59:17 -0700 Message-Id: <20250418015921.132400-4-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250418015921.132400-1-dave@stgolabs.net> References: <20250418015921.132400-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 Reviewed-by: Jan Kara Signed-off-by: Davidlohr Bueso --- fs/buffer.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 5b1d74c818e9..f8c9e5eb4685 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,7 +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 Fri Apr 18 01:59:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 14056586 Received: from coral.ash.relay.mailchannels.net (coral.ash.relay.mailchannels.net [23.83.222.39]) (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 8A42D770E2; Fri, 18 Apr 2025 02:38:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.222.39 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744943894; cv=pass; b=GHkBugaK5Cl441Gw/FhKtJk0/VOeYcpgsZuhsepkLJvFmEz3HgBNbVBBYhBar+UuA0ZVtA+zZirmHz3aynfJXwIyhW048BblyrL+jJ1dyJSJ60VOMnc7rw2m/6QB7Evidf8GpbzsxjjbbUS7L2q1UHU6teqeIHG7UmjJXqLY3sQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744943894; c=relaxed/simple; bh=caXlnD2oHiRYk4Cd+v3z9Gfe8ZSs6QrQWezKNp5Wa0g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q/lahEPLE5HWCcbbvi19TSBjHBV6S1tAq4ZZ9hGFnUzTBwaiPBQXpkg4+FBW+Lf5XjN+yd4eOGsZGKH2zcqjl/mErhsxdooDdHdrGCTdAkh0zOUj1TfP/p9nkKeJp4YBzair64B7sdHP0hOAkS922x+h92GfkYuFqMQUPUK43/w= 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=kpdvvT0I; arc=pass smtp.client-ip=23.83.222.39 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="kpdvvT0I" 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 6A4B14E3E63; Fri, 18 Apr 2025 01:59:37 +0000 (UTC) Received: from pdx1-sub0-mail-a285.dreamhost.com (trex-8.trex.outbound.svc.cluster.local [100.110.156.188]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 0ECC44E3DA7; Fri, 18 Apr 2025 01:59:37 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1744941577; a=rsa-sha256; cv=none; b=9z4NAulcqZEtIT3DSYAMJEEzyHl4OUVDXYUa/u5xxIbUVEx9loFzXyemUYJIxCWwdjYugU WVF1FilRhnoPGcGgKkwBwVfepuUU+AqqpF3wAA1KcaG8DZbz/nIgk9g1NTLrx3uW6NYbyn +b/V3NaPWumOJic84c6hJowbpt0eGJ+PO5jbunEdw72a2KmiKWXfJ2HOPUtHgjV9irGf6x ymgpFhEeG3oIadQhFKeXeJ5C/sirbDB3bfPjKFoV0v16fYNioIpl8r1LN0rvGYNtpr38zT P1FzH/j3/aENh8ndcvWFl3cunGnzuk0PdkKns6nGngAdcG9fM2inhua8M0UgjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1744941577; 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=MabBCGA0m9wa8fg8pahJUNB3mGjC5+Tn6ArLhv/vZP4=; b=f90j+YzQ7hjLmbPv83G8gY9IV1ngRf+fEsgixVWiTHTW34CL04W5yZhP5quyBOfr1nG4sz WwuXcWe6OJOxnILNXMKEecU/l3HkvNTGImZohFuToUOLb+gLH6XUYJJzPWFgSARgULnusF ibDXExRqho6UW5OK1/337w/kviXgddoOO1mzTPCB/X51rWMKAVznGP7z4QcBTzp/GzuRIZ pxUH4WR014BcLc5wosFrmtvAbytHTS6lGt8Hh9xXJv8ExN1kCJXrNYSkjIBz1tVHA6fQp5 rBqYWsMYOWd0/2K9nKxhqyR+L+POmNVJ0fwLtJhTKHUF5MUGqCoeBTlJHtusuQ== ARC-Authentication-Results: i=1; rspamd-7bd9ff6c58-xxcc2; 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-Chief-Stop: 39defe2a79e53d38_1744941577351_2613637192 X-MC-Loop-Signature: 1744941577351:2941586493 X-MC-Ingress-Time: 1744941577351 Received: from pdx1-sub0-mail-a285.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.110.156.188 (trex/7.0.3); Fri, 18 Apr 2025 01:59:37 +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-a285.dreamhost.com (Postfix) with ESMTPSA id 4Zdycm1J43zC4; Thu, 17 Apr 2025 18:59:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1744941576; bh=MabBCGA0m9wa8fg8pahJUNB3mGjC5+Tn6ArLhv/vZP4=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=kpdvvT0Ib2FwXMXNFIsJ1B3ejhEV1qHORy8ifsLmPDuDI2XKOMNKHFP5Rw0CyLl6w rR7V8hLj+GfhGeWq4jzNR3MQZ8cgo84qj8xXYxoeLMTWGMFoKm55+n8ZLsPgH8Aypr wErbSM37TrMzASGozlXONJ4ETYCh+H9xLho51IyRgg7sqopDUKLBRXEkzinUEH0/Eg fqka2BRDE/gaK4M5naK6mkgn/RN+5RRk7FawYGfUHZf1Gy5gbN9i7ubDYRxOs921G3 +trPpaHa7x8wUg9nakawBIH5pd3uABIt1rk3+wl80IGVPnZdyuX0hEpjlKqANg5W7O A5iiKcalfiCKw== 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: Thu, 17 Apr 2025 18:59:18 -0700 Message-Id: <20250418015921.132400-5-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250418015921.132400-1-dave@stgolabs.net> References: <20250418015921.132400-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 Reviewed-by: Jan Kara Signed-off-by: Davidlohr Bueso --- 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 Fri Apr 18 01:59:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 14056536 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 96BA4263C92; Fri, 18 Apr 2025 01:59:44 +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=1744941587; cv=pass; b=ewxb5FJb/7lUrrv0zHt/tB/bU6XH6podR37K/xJ5FTR5jhnEG0wFaLh/UPthrw5UGdWXzdwGGE6nZ5aJnVU+tOX9y94jn0Ea45e4LYir04+lkCFTelhgSPAAxBrNqmFlkHVVKUSiNetp7SwsNMBjcYvvP7z3trSPcXudG7Q3PqY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744941587; c=relaxed/simple; bh=YrQlA34UgEDnZhIwTgoLDnvQxHt5wzV7K9XFumD5R/0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mhJO9bPz9zqBrsCcEQufmXEuI0Dx4Tg+XfghUFGbL/ZOipKW3rHK9jUgnHGKHjIDNjFxIYBEemPgWVJ6P3wfh2EBVEIi7uChR5XYSdTlnQuZ7X6Ns2/6vEqJRt0h/4w5oy9nZ9bhnvwQX4HPxyCpUpANax0Rih3uyQ+PAqm4/ZI= 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=aP42K654; 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="aP42K654" 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 550DD1A39AF; Fri, 18 Apr 2025 01:59:38 +0000 (UTC) Received: from pdx1-sub0-mail-a285.dreamhost.com (trex-8.trex.outbound.svc.cluster.local [100.110.156.188]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id E74541A41CB; Fri, 18 Apr 2025 01:59:37 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1744941578; a=rsa-sha256; cv=none; b=0WM6aWy1czVlh004anQ08oBZzarf7qbIHK49l2C0PNci6u4idl/fYd2oOL7O3Y8RB+5IT5 eIRenJTXjk8ecCuiP9++rvOKQYT8Grmm8CfwitFMCmo9TXfd1nPI57+1dCq0AMFiyAB7aS wzvrvImtI6kRz9vIOHtNFleXwqkjRJHvsGOGso3Ui1r3E5Tf7zWH2pmhDGYAgFU598ckla kJT6mlhVKwK3YMyYyPYbabwGXgV5V8vJAVMRSKUSul7rZI7B/ssvimUI87/gOHLX6eW+3g A575Y8ARzjTwFNjIQCZjZTMNH7GrZNtuy0TOBL6h317OW4xSBoiEMCBg3a45vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1744941578; 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=zEOAmzE+sZv90XpMJsEcv1fdnAY2ZyFOCOVC4uAZkCE=; b=PU/jGGb/J/pdwkoeDhPVnnQ4+TkiUQYWFsODQbLXS2Gb3LgrfZcZ4L+l/JfWy06arnVuHq MGUob08FU78E/gYmQ7v59FXZRILmUcnglGL61EnV6t2tmBWT72PWvLbwnO6LXvlOFG8s5o Mz+Nk5lDTtRZX/4XhLhqwUAHjDLg+NDeAbIOenJ+Pm3G8bYfVNXlfkWFrDVXrLeR7Ey8j+ iKmlmK6wLwfo/KhpwM6SkFkSIRc57h/I/0mQOWhjvzyDbdTAjdLpapgSSN9vAGojFa7UOk 8e86ZLSAfj4OzBcaBCSWCJO1ySAyiE2cDLsCux81G23Psjvx6eIl249vEi9BxA== ARC-Authentication-Results: i=1; rspamd-7bd9ff6c58-xxcc2; 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-Desert-Broad: 4c3fb7e5001df433_1744941578239_2862724236 X-MC-Loop-Signature: 1744941578239:1903151097 X-MC-Ingress-Time: 1744941578239 Received: from pdx1-sub0-mail-a285.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.110.156.188 (trex/7.0.3); Fri, 18 Apr 2025 01:59:38 +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-a285.dreamhost.com (Postfix) with ESMTPSA id 4Zdycn0ZBJz88; Thu, 17 Apr 2025 18:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1744941577; bh=zEOAmzE+sZv90XpMJsEcv1fdnAY2ZyFOCOVC4uAZkCE=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=aP42K654m4vLdWbMLGpstTsOj6HsVlFIbRoEsYxp+M4l5rHuQOLl5s3Y+Uu2yyleX e7toEc9FSD/kcVOlHq8ye4gVpURDInp3MEGBc+P8h2XaOn1VhlTnPe9ViOvH5zr5Ld jCKEEkgIZo2HR7iAa45LPOHY3ffMDrv9M6TGCNyjAf+1eoA7d7kRiNuv01sQW+YmDu IGZJNnKnKepZ3Q9FXW9acszetdtp26TcO1yAUlbK4oeyE4gt0nD8swfNvZlF4ipmTy aIFU6+ooY/Apvfeh9Gk8xtdeBbs3SHKawZrL6PU9TLpbIX5oUb+WEsMgmrbxsUEi4l TLnezOQh0Hxag== 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: Thu, 17 Apr 2025 18:59:19 -0700 Message-Id: <20250418015921.132400-6-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250418015921.132400-1-dave@stgolabs.net> References: <20250418015921.132400-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 Reviewed-by: Jan Kara Signed-off-by: Davidlohr Bueso --- 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 Fri Apr 18 01:59:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 14056537 Received: from silver.cherry.relay.mailchannels.net (silver.cherry.relay.mailchannels.net [23.83.223.166]) (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 987D0263C9B; Fri, 18 Apr 2025 01:59:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.223.166 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744941587; cv=pass; b=khGp05VS1HJy7FecZK9Q3NPwjlbYSGuyEkcCNsJgvQ9pWmfQyZttFMOH3qgiG00ZCEsCHplDDYVSe0uWgDlAsBastUDOgaPndJFeNvAK0pYPzSfVezcrii8x8oHj2GYFhTvdn97MHjJqJ09O+5SGGzhs1QKqboHyUnnCS0tK5r0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744941587; c=relaxed/simple; bh=I7YmJPVxFz9nOaKxkJ+l2msdjZcfJtt7f1VL7dLDwwA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UrhNXWQ0MSxeTW55eWHJyCGxGxnfa1p9KanZ+LyAZgbq1aehLnyHF7Zs7eNvWdybJXYjpSYzWQOpLlTF8UgOWb/LIzLoXKpY5zyybyPvMlUdspegzK/s491kGY3bpOXVQt6Yuh802cii0Oqsvi8IQD4S84XUVMTkHyPz8TA3B6s= 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=b1brf5x1; arc=pass smtp.client-ip=23.83.223.166 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="b1brf5x1" 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 3896022B93; Fri, 18 Apr 2025 01:59:39 +0000 (UTC) Received: from pdx1-sub0-mail-a285.dreamhost.com (trex-9.trex.outbound.svc.cluster.local [100.107.106.146]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id C7E9223AAC; Fri, 18 Apr 2025 01:59:38 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1744941578; a=rsa-sha256; cv=none; b=bsS5tFD0sykfK7zgraiMxA6Hqu34fBQvGqp/gPVXcbn9Ae7yU7jNNc8UR4b5rAXNa/rm9P cHrD0gwRYU7YUn8R53I5Y06jNSSvAdw8T8wBjFLoKlMc1ijYYBvHIYZszAWZsntuqztV+8 tiMp7EG9joNDpwQSC30WAiKTGI9atNHK5zKtTADNVYzhWXdfyMGl0hbhTvozI8YsGjp4Pw YerUN7Gnxv/1kJS4NgKUVtmBIFh3748BU8PXyjCWBtBMj3rgMSw5iiNDuTl0mM1uTxehZ0 /ne1HKj6YsKgcsGWrtgf3rGcaBIThc8aXi8Cdy1puedBdvmcuZywFlVspMhrZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1744941578; 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=hKmDLBznBthDscmA9sgDkTXs0rwbYUAQtB+GXsoJPYI=; b=ECo5BCDzyir7+TlNjGln88KUGmCcrJNuxMMZ+EMa/uoxAkwoGjTgPinRzSSD/VIrbwBZu3 5fTo6KNMLJfRJV0E/SCPpTgwIee4/xZOXej5ykmRgQ3DQ5KOXg8763GIRIZSldd7h+nMyt 6HYp+LsqACtzOtweUC/f7EXPaxvEnuS9OoEAFPik7kvzb6lCbf9p2OzW8GcKkCpa3O6VfT 84IPngyaw5h0Q+phAgCfUUF2yiwg2RqY6PJnm5vYxJU4subqvEkzzKOgbH+0NZRI9N8EDA EObJrViW4yWeGjj6W6jutGER1Qttej6EpeoFh7gqWNs4gAoW9bxZjGE1+6AQWA== ARC-Authentication-Results: i=1; rspamd-7bd9ff6c58-nbb74; 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-Cure-Invention: 47318de774abdd5a_1744941579134_174818650 X-MC-Loop-Signature: 1744941579134:3745978050 X-MC-Ingress-Time: 1744941579134 Received: from pdx1-sub0-mail-a285.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.107.106.146 (trex/7.0.3); Fri, 18 Apr 2025 01:59:39 +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-a285.dreamhost.com (Postfix) with ESMTPSA id 4Zdycn706VzC4; Thu, 17 Apr 2025 18:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1744941578; bh=hKmDLBznBthDscmA9sgDkTXs0rwbYUAQtB+GXsoJPYI=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=b1brf5x1RNdEsMHccWQKbPpYYmJhWv8TlrH44E+XtoDEKd2xqrNlBhefpOMfAOxAR Sgn57LrKi2zczUgmDPnStSt5fhN+u0dEp6udEBvEL9X7oRZOPRWIhH/dh8yNVMBOTI kTenPmfdOZ8eZkNf9+JmzTlEpWVpNm/1OV7l0DkFqk+BEtZT4uAh6p7pM3Q31RjC/v 8Ev5BN3zhcnT38dqvqXDWyP9xkJMkSKlB9K1g9KM7Avj1F2gFvBT9MSo0sLKmVyEyo e4Prr0i0XeH8VNUbF2FtnJdU+sjO+J6uJNmAqdlelEQLCQPndPfWTg4Ng499HiEQ+E e1oe8wdmdIxBA== 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: Thu, 17 Apr 2025 18:59:20 -0700 Message-Id: <20250418015921.132400-7-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250418015921.132400-1-dave@stgolabs.net> References: <20250418015921.132400-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 Reviewed-by: Jan Kara Signed-off-by: Davidlohr Bueso --- 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 Fri Apr 18 01:59:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 14056559 Received: from siberian.tulip.relay.mailchannels.net (siberian.tulip.relay.mailchannels.net [23.83.218.246]) (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 D5D63266F1B; Fri, 18 Apr 2025 02:08:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.218.246 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744942100; cv=pass; b=XNhPgVBZNN9NEhV41FVl3IdUqqOww5iSwOBd3REC+X0Q6YKHkIVxwq1/VFVMWCOIwZhzAwcKFns/rYakoyWRU781XsoGng9pvxCeBcn7/G+rmRJL+UJIruYJ521wgYi0e5V87Tq9I5nQ3Jagoz5bxXvjC5YU/dU6pw6wz5PdQHM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744942100; c=relaxed/simple; bh=vcz9OUUPWUbPr1TN5zTl4x+JXmo0eA8S4HDdoyUGBPs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W8ynSVMQLScW9PmhxDhB+qvoGCNk8TKhhKKi/ExQo+7Jk6KeyvHj/YAGb4XEn6omMg/+6zv38TEXsvLtNPv3vapJg0k0ptRMKNiXe7gU5Mu1aSwzxtEM4Zdmee9NNwmeBMHRUxZKwc2pBvXBoD+3i6K4t/8PNYhLAS5Df4WQYak= 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=ojM1hAs4; arc=pass smtp.client-ip=23.83.218.246 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="ojM1hAs4" 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 2AA9643A62; Fri, 18 Apr 2025 01:59:40 +0000 (UTC) Received: from pdx1-sub0-mail-a285.dreamhost.com (100-109-225-168.trex-nlb.outbound.svc.cluster.local [100.109.225.168]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id B7F6343E8E; Fri, 18 Apr 2025 01:59:39 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1744941579; a=rsa-sha256; cv=none; b=ns7YySgcYYnM8Kj9r8WBG/+jq+NUBrxn19NPA+MoKeR+9VM4j49HT5uLUSQpThCedSk4DM bJ1z/Q2crqPYVt3ONDhMiwMkfqj1En5xCZgJ0fq//gTIzD1zvqZwJF42tKxqVtYeJb64Pl ZAMpNm0nMP2zMu14RkMZOXB0c94c5H4OF9q6Ke1mxnk5OpnkmCPLI1mCORUUbLmNIrSQnm 1vU6zysbz7Q0YDi2kcecw5aeRjl/adN73hWeMk0mVhOtR05b519waAaJiKuMzt/facjYYp 87IkdL/XtwQ4U5htLUD1LZGaCQGw2XbwBib+BnwbnKYEMgjKce3C4x6A4hG3cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1744941579; 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=mLuy4zj438a+1U7en1XTc2so8/rQx/UkGlXZZ4fu/o0=; b=5dFXA76JGdkkLY43IAR7iR52xYZ9W/2hOmYt6L4Znss36zGhTQnn8roHAA2YKmwE6DMf89 Fj8ocyUz+gMZGUoOUW+tw97h1V7yLjx4UM2ce3O1vXUMCrCnpYVqWbiCnGRS6Yd2x+YCBZ ZdBtXGv5HXEFyt/cSAR4n9WqdeAn6KdgGhCBHU7xnsbocDHPx4LjaFT+niQMvYwwALm2HK 7uTi/ZQMunH0saXX/Qzw7D+WNLHbB/aAxM/I4epcQFXiGSDC1zVRvO77Wc0+S7VfVkOcSM vVjJalJevndsJakSsjU7SDGUA091uVTahWPboMYWGO+bqVoOTpP2gmloNVCNNQ== ARC-Authentication-Results: i=1; rspamd-7bd9ff6c58-xxcc2; 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-Arithmetic-Illustrious: 0fad6dd04f8ec142_1744941580073_3053416635 X-MC-Loop-Signature: 1744941580073:4085039856 X-MC-Ingress-Time: 1744941580073 Received: from pdx1-sub0-mail-a285.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.109.225.168 (trex/7.0.3); Fri, 18 Apr 2025 01:59:40 +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-a285.dreamhost.com (Postfix) with ESMTPSA id 4Zdycp5xX7z88; Thu, 17 Apr 2025 18:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1744941579; bh=mLuy4zj438a+1U7en1XTc2so8/rQx/UkGlXZZ4fu/o0=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=ojM1hAs4QuyGMN5IMykmxoNDnE/XSho9YWg2f3+vjt9onDipMWmdlnrV9vBWEe+9D Y4rzbAtGkyIvbHF1mBxxYraGhEG88LxouC7TxUjznQySZEbzHQpgLPWYol2FiQt6Ue MOr7emUEtui7A/0wQEgdKQMsciO+SK6i0V4FWcXVGSXBIlKqC24NNmp7j34BnFPlFg egX7k1DS97Bm+aA/D6ErzxSfg68rfpkHnY1IMMCiCRfURy726xm+HxldOadS4JfMB2 SwYG5xviqBpseVjKf0jrHIuY5BVKwAXfzk3nEKlrt4j4hVSDXRYMw0H4OcIS8TeRRc BMjzIsk3itaNQ== 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: Thu, 17 Apr 2025 18:59:21 -0700 Message-Id: <20250418015921.132400-8-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250418015921.132400-1-dave@stgolabs.net> References: <20250418015921.132400-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") Reviewed-by: Jan Kara Co-developed-by: Luis Chamberlain Signed-off-by: Davidlohr Bueso --- 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(-) diff --git a/fs/buffer.c b/fs/buffer.c index f8c9e5eb4685..7be23ff20b27 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 f3ee6d8d5e2e..676d9cfc7059 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,7 +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);