From nobody Sat Feb 7 08:43:02 2026 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C529A2E62A8 for ; Wed, 31 Dec 2025 02:55:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767149730; cv=none; b=QvwiO2g4ShCJfnfL+M2tKozpZu8reopTMB81MJzHMBv37O8veUSKh8vm1VfCnY8x4jTmsuFaHs5kZJewO+8JOH9E8MvyY67pB5a5/a3F6t3P90gvYPlkzWMqO5+B9SXljLWToUF0/W2v/P6mgZOMkNc9gpiLKikczcmoEwL1gqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767149730; c=relaxed/simple; bh=w1Epuv8pplEL0CHRjiqpgO68o19GjvzKVSFTQ/iERRk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XhZnAYu0WuashvCZTQkr2jQjDdOVfY5BlkImtROGMFeh1W1rhg9ymFCAPu6C3i7FWM4GVxuJ79erDx71M5GTgnlapqbIzZd+kmbpSCV6LnJqjcGsYavFWhdXoQNAAMXcG1cTEsrUATqAQQVpN6x6MDX+d2gSgfs82u9cqu3DLuo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PQ2lS/m6; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PQ2lS/m6" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-7f1243792f2so7016054b3a.1 for ; Tue, 30 Dec 2025 18:55:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767149728; x=1767754528; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ovFZ7nDpGXAGjzX1rK/nF0C1dw1vDfNt7z4qsrWCWJw=; b=PQ2lS/m6xVR43MYALQcEXKGkrLrqODYxOZDmTvpL1wlF9ZFreFNLoDP2EX5gRkzbE7 wZKCqmAcc4lsYm/6HK29ud0NBE+r/17xaen+GNpPAPG5ZLhYML5iBItX1GOvkg3xMDCp 42y9esTtVBJt0BioiBEHpHAdVXs8qw63IHUqLolL6SxdbdqcTop+7TPGGMKoJEidj4D5 j6LnxVgOtaC/35y2/M4nVTuK+l7kqZMvFuRgi+eA/M2Z8r1z9sp6YfrfWyElE6fS679F OfhGiE8YNx7jrZN9E6CoPBHAJwO83xDVs1Go2Nk9XKHJHT+aDtPRrgxMt+6X8/sqfRj1 mZgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767149728; x=1767754528; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ovFZ7nDpGXAGjzX1rK/nF0C1dw1vDfNt7z4qsrWCWJw=; b=WdJkPmZ8+xZlmL5AQohpiyNjC4UHoTm2OXMNW8zeY3j4PDO07SH5cDPUoT9suA9Dtg pdfFnQToqRjOMrHr5qUkwb5MqQ81/2uvuOjHIWWMh9Cac1PYmNEwrbjtlUH0816tyT+p QxdNOJMCkWrJatdY2QxbPEBLwXOPyIXvTo//9Gywm5vOsCJ7ump1PuZrUd8YpnQbi8WM eb4n58+hTFSbHmWaicPTM6H/Hw7pakIqg5R8dElKEJKQW0iiCMX05jeMdQwcSW3eINYB wgSmW+h4ycsMOka47pwcfZUOMgzmSH2ntB9XQLodhhiK+keN4JCuFJcGZnHEhWElVa85 Vg1g== X-Forwarded-Encrypted: i=1; AJvYcCUYCG5fJAjPJLSXgh0Z1Sc11n0Cz4ii8v3vONzgRec/QzgQlO7UAs1bqM+bDZTEHhhEzW8rl1k1dbex3Ho=@vger.kernel.org X-Gm-Message-State: AOJu0Yw8XjcQYlQI7FVYwSpOfp6e3iwT5Xwv3DAE3NyDMZlaH7UTyg54 7w3vUTbCikI9mOFM33LzLX12NStkgkcWEIddHlAdQMIpvPompTNTr9X3 X-Gm-Gg: AY/fxX4SJjVm1xEitNUxXvh2YbdxQFxWsCcDpvQ/ne5AHkHpvqvxh9xMy/Dv4BooHYF GV6aH75C9KScXE/z2osmZRTLNLA3eIBLCZCN3bMRF8ZsGUdkHgs/E+hYod93Au9DW3KV4j3S3FF gtDpbQnmykRNs4/JELCC59zMlDAd9grGvNP4zw8ip06mBaChPvdEwasSpk8woc/cpozawvJxmNH AlTpzBY4kB72fPxli8yzezDBnehZ+/4Mh7BicJsVs5llARc+VukSrP1BB2/3p6W7EDZiCL1P1Rh Mfbr/EcIc1gn5N+jOZqTZjv/d/kC/kHE9u2ukHXQ4Am5oRbqNN0EXJzG4jG+y/ZbuV5rU2Fl69x ZpbFuRZ80IMB9efNsXOM3iEge+W+RLse1jeLTCEye/a7Kwa8z6e4Ry1GZW9ZlYpzsBtkXke4JEu YAvQ== X-Google-Smtp-Source: AGHT+IFjVb9L7i5dRy0ErgLaowmMDW/jAgagrfbQrXsnKJtMt/MDazwp5eKXxShX9HNXUzfl7Ik/Yw== X-Received: by 2002:a05:6a00:1d14:b0:7e8:43f5:bd44 with SMTP id d2e1a72fcca58-7ff6725797emr32738775b3a.48.1767149728092; Tue, 30 Dec 2025 18:55:28 -0800 (PST) Received: from celestia ([69.9.135.12]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7ff7e892926sm33623646b3a.66.2025.12.30.18.55.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Dec 2025 18:55:26 -0800 (PST) From: Sam Edwards X-Google-Original-From: Sam Edwards To: Xiubo Li , Ilya Dryomov Cc: Viacheslav Dubeyko , Christian Brauner , Milind Changire , Jeff Layton , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Sam Edwards , stable@vger.kernel.org Subject: [PATCH 1/5] ceph: Do not propagate page array emplacement errors as batch errors Date: Tue, 30 Dec 2025 18:43:12 -0800 Message-ID: <20251231024316.4643-2-CFSworks@gmail.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251231024316.4643-1-CFSworks@gmail.com> References: <20251231024316.4643-1-CFSworks@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When fscrypt is enabled, move_dirty_folio_in_page_array() may fail because it needs to allocate bounce buffers to store the encrypted versions of each folio. Each folio beyond the first allocates its bounce buffer with GFP_NOWAIT. Failures are common (and expected) under this allocation mode; they should flush (not abort) the batch. However, ceph_process_folio_batch() uses the same `rc` variable for its own return code and for capturing the return codes of its routine calls; failing to reset `rc` back to 0 results in the error being propagated out to the main writeback loop, which cannot actually tolerate any errors here: once `ceph_wbc.pages` is allocated, it must be passed to ceph_submit_write() to be freed. If it survives until the next iteration (e.g. due to the goto being followed), ceph_allocate_page_array()'s BUG_ON() will oops the worker. (Subsequent patches in this series make the loop more robust.) Note that this failure mode is currently masked due to another bug (addressed later in this series) that prevents multiple encrypted folios from being selected for the same write. For now, just reset `rc` when redirtying the folio and prevent the error from propagating. After this change, ceph_process_folio_batch() no longer returns errors; its only remaining failure indicator is `locked_pages =3D=3D 0`, which the caller already handles correctly. The next patch in this series addresses this. Fixes: ce80b76dd327 ("ceph: introduce ceph_process_folio_batch() method") Cc: stable@vger.kernel.org Signed-off-by: Sam Edwards --- fs/ceph/addr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 63b75d214210..3462df35d245 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1369,6 +1369,7 @@ int ceph_process_folio_batch(struct address_space *ma= pping, rc =3D move_dirty_folio_in_page_array(mapping, wbc, ceph_wbc, folio); if (rc) { + rc =3D 0; folio_redirty_for_writepage(wbc, folio); folio_unlock(folio); break; --=20 2.51.2 From nobody Sat Feb 7 08:43:02 2026 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 259D92E265A for ; Wed, 31 Dec 2025 02:55:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767149731; cv=none; b=t8W2vUVNFw1UFr7IZOEPeHA+mjEzF5ESVL2yvNVUvrFyO8AeLIBobCrVFGl0RZe1UGsXK8mgVB+CFvxSl8+DFhFWNd2R9bp7OR5jP9nKWGkoKwxRTEZUjxHQ46+yMojQXV51Mk3VY7LKYX12ZDeJgU/ybvRAhKGKkXRuGGEmM78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767149731; c=relaxed/simple; bh=+OMCjLpYjNGGYfZdJjYQd5xrfdW6cvuAZrYjo1yzsPw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MH7J3K/gYVfhJ/4W0/BjXx83ugioW78SPBskF9tUcrVxE5V0/nW7ExNtsLrsDYRVydhcFYhAybvp46iiHz762MCY86gdgPJ/qq9nlGD2PJTYuB+IgM3h+YzAcyDvWqNcuwyVn77lHrkuooqvhh2zpogJJzrRhADbEeuSfbiUYUg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DvhvGZDI; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DvhvGZDI" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-7b8eff36e3bso16747758b3a.2 for ; Tue, 30 Dec 2025 18:55:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767149729; x=1767754529; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GD9+M0L1TL+nHtGjY77JqppAv2xqxZhHU8cYw4+7xmc=; b=DvhvGZDI4/aPVk1jwVhCuXr4IhEhVqsZQX53aCAUkzht95vhJJcEcIDpPWtUeiGS3v 5pHxJQfUYepLu/16Oezg/5si+fX7QC3iooQNz76+2AEqx4Rb+R+KLsA0+ONovKEGs8m4 BTjCjhIwxBv7JxYkkaroiPCwKmn9xwDWRlo+99clBdRjdU0ldLrfFrLF6vbu42S8C9u+ 2pLEMMNgAVvGDyaWYSfj42dDwEjTMvkNbRQUM8Ri4wiBgeIXdFsT90JxxPx/nC4XAiBy Jbz99TxY1NR5eeN8G0C3tEDLfmA8jKZLEvGbfhL86tjUARFhukQIVmo+djosLTOEm1ke kTnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767149729; x=1767754529; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=GD9+M0L1TL+nHtGjY77JqppAv2xqxZhHU8cYw4+7xmc=; b=A4VaAqTyXWAcvUSBqKJTRvYJj/kiAURVdlPyZAkpISzB4AMQEYcj12CpRZTiRsIzYS oIxqE/jUe0uUCOE4+0gQpBK/vA+rNDmojSuOFGYlDdyY3sGXcUFsJhSTNiTxA8Sjep83 alfVa4zX1UyweQ0p6TlE6SRjKEw2SfOpJVyoL9i2oZ1X0BeDQ9mlenM7k2wrUjpCEyZM ZmYbqlKGBJYZ606tSBKQU3bShwJbeaJ29yVCuagKU6FU8T4A2q2E7tmAk/WivgAZ7Bao EhTv8RIvh+bCg+k+wg7dcwbJrkVLeSnT9WvJYuNQG78+YdiAvpusDsxvQCxcL2a5a3v8 8hRg== X-Forwarded-Encrypted: i=1; AJvYcCUOF8b3RfKh/V1u6q2eFie4o2LKj1ViXIkQ6GufMYYHYk66MAfmzSI+Ha4efKDPlGQH/9yBtOGuSQDxczQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yx52MRU1QclA3nTpeQmKsQOqn8mnCGEHYWkmRnXkEmW8qRcwhy6 +OKf1G5uqoU7wsnIVvM3WzhRvsmo4G47vkj3Y045AaoHwYRwcfg19/1I X-Gm-Gg: AY/fxX6SK1m1xavptEH5R/IamuO+KS7EZftJz76VPvyYevrCi2gtzyETi6rhMhAvgkC aSCGN+rb6o/OP/CaEio1aHmTU79KSXCJ92YHTgSVkgsnAFYMtiXydUxKujWDY6paM4k6bVE2vxX tFiTN7HgwVxgc5zFDDneCjgka5H5oG0as8vkpAUoL2VAyH1hj5P4IrQLap4j74D66LM1z+waqnK P72wDXi4BcB0dsQ4+CjZLGG9y1k8z7UB1V/JiBzInpmdwPXEVOOvVEB/HlQZh+shZHsIKyKVrxZ p6BSCgSUVA3tJHr/tz+XzFSlPgKKm5k8UmXQP/PWshqEzXQvvFalFK8L7IjhuXfoViUnSQWRsPQ Xr5QWHKgo5wWGBqskUBFN+kdnN023GyK+NnfUUomqwZqRJj+wuryjDFs07HNeb765E5HK3b/dkl Rlpg== X-Google-Smtp-Source: AGHT+IHQhHz2NAHmsBdYzxrrHSUZCSsyTkuM4/dUNCL/zI9iHymcmkwSgPqKvYSy6Vi5rp4ER//TRQ== X-Received: by 2002:a05:6a00:3316:b0:7e8:450c:619c with SMTP id d2e1a72fcca58-7ff66a6a6acmr31156344b3a.51.1767149729370; Tue, 30 Dec 2025 18:55:29 -0800 (PST) Received: from celestia ([69.9.135.12]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7ff7e892926sm33623646b3a.66.2025.12.30.18.55.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Dec 2025 18:55:28 -0800 (PST) From: Sam Edwards X-Google-Original-From: Sam Edwards To: Xiubo Li , Ilya Dryomov Cc: Viacheslav Dubeyko , Christian Brauner , Milind Changire , Jeff Layton , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Sam Edwards Subject: [PATCH 2/5] ceph: Remove error return from ceph_process_folio_batch() Date: Tue, 30 Dec 2025 18:43:13 -0800 Message-ID: <20251231024316.4643-3-CFSworks@gmail.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251231024316.4643-1-CFSworks@gmail.com> References: <20251231024316.4643-1-CFSworks@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Following the previous patch, ceph_process_folio_batch() no longer returns errors because the writeback loop cannot handle them. Since this function already indicates failure to lock any pages by leaving `ceph_wbc.locked_pages =3D=3D 0`, and the writeback loop has no way to handle abandonment of a locked batch, change the return type of ceph_process_folio_batch() to `void` and remove the pathological goto in the writeback loop. The lack of a return code emphasizes that ceph_process_folio_batch() is designed to be abort-free: that is, once it commits a folio for writeback, it will not later abandon it or propagate an error for that folio. Signed-off-by: Sam Edwards --- fs/ceph/addr.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 3462df35d245..2b722916fb9b 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1283,16 +1283,16 @@ static inline int move_dirty_folio_in_page_array(st= ruct address_space *mapping, } =20 static -int ceph_process_folio_batch(struct address_space *mapping, - struct writeback_control *wbc, - struct ceph_writeback_ctl *ceph_wbc) +void ceph_process_folio_batch(struct address_space *mapping, + struct writeback_control *wbc, + struct ceph_writeback_ctl *ceph_wbc) { struct inode *inode =3D mapping->host; struct ceph_fs_client *fsc =3D ceph_inode_to_fs_client(inode); struct ceph_client *cl =3D fsc->client; struct folio *folio =3D NULL; unsigned i; - int rc =3D 0; + int rc; =20 for (i =3D 0; can_next_page_be_processed(ceph_wbc, i); i++) { folio =3D ceph_wbc->fbatch.folios[i]; @@ -1322,12 +1322,10 @@ int ceph_process_folio_batch(struct address_space *= mapping, rc =3D ceph_check_page_before_write(mapping, wbc, ceph_wbc, folio); if (rc =3D=3D -ENODATA) { - rc =3D 0; folio_unlock(folio); ceph_wbc->fbatch.folios[i] =3D NULL; continue; } else if (rc =3D=3D -E2BIG) { - rc =3D 0; folio_unlock(folio); ceph_wbc->fbatch.folios[i] =3D NULL; break; @@ -1369,7 +1367,6 @@ int ceph_process_folio_batch(struct address_space *ma= pping, rc =3D move_dirty_folio_in_page_array(mapping, wbc, ceph_wbc, folio); if (rc) { - rc =3D 0; folio_redirty_for_writepage(wbc, folio); folio_unlock(folio); break; @@ -1380,8 +1377,6 @@ int ceph_process_folio_batch(struct address_space *ma= pping, } =20 ceph_wbc->processed_in_fbatch =3D i; - - return rc; } =20 static inline @@ -1685,10 +1680,8 @@ static int ceph_writepages_start(struct address_spac= e *mapping, break; =20 process_folio_batch: - rc =3D ceph_process_folio_batch(mapping, wbc, &ceph_wbc); + ceph_process_folio_batch(mapping, wbc, &ceph_wbc); ceph_shift_unused_folios_left(&ceph_wbc.fbatch); - if (rc) - goto release_folios; =20 /* did we get anything? */ if (!ceph_wbc.locked_pages) --=20 2.51.2 From nobody Sat Feb 7 08:43:02 2026 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 331692E8B66 for ; Wed, 31 Dec 2025 02:55:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767149733; cv=none; b=ZWYk6BfrdsX0+AsqELE+zZ4MBh+5SuwXqYHoNIq9xGwQlBrmp4OzqwtHD/8meWbQ//1vTFtNzMNsDwSoem6uEYuxUq9urM7qkamwVINShFAaD9XtAW+DnKdsaucYMH4p2eP++PQPUjNywPzsNEaqJlrfR9jW8W3Ue5bmR5hcwO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767149733; c=relaxed/simple; bh=2MYN99jAWMQpINhvGeEWth578u35RLmt80tvIG1rBvQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sWMKMweJY73ht7YUVUTd1aID+sDCC9CD0lqjwsgp3Zkta5a1CuAS+Rk41JOmyBBxhVtAkZfmwsPQlXZHinIG0X3jow0to0U/booxmrktCrdrk+t9ZkGV8ge/iOrpakbLWUCq4UY2j3xzpJpGwhUwIWjBGGEvJdhJpY8y8KeWnKw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Xw5O2WZq; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Xw5O2WZq" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-7aab061e7cbso14133818b3a.1 for ; Tue, 30 Dec 2025 18:55:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767149730; x=1767754530; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WD8xYCq07j/aj+WegcGPJWer+Tc/bnFPxdD4Wp5XP0Y=; b=Xw5O2WZqu+0d8OEAuJi4mL3abvMp2lybFKx4CXtYiBTZtP1EDq2Rnq8qyvcoa+AzDY T54bl6tkq+MWXAQFn92cbGBUTu49Fz94EWk9ROgKTXCRhmfboxXnxcG4onOmzlV1S6Yo ORjlJamX6xTw6YoiqSRCWwccx3p4I8ejzLoyYQqdvAEqlDVPPG4gVeiWNChPm3SMg5oi Xmw+futbmadY39MucZk0QLh4v6gWY5mXXKoInubl8+cI93o6luY41Vh8f2SXB4BIpcP6 bBe/4Pk93hv6wxcY2d7qE3XxN6n0Bc2KblFDNoJJllWbgLSx5kjin/77PyrlS3+PmcaY G5Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767149730; x=1767754530; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WD8xYCq07j/aj+WegcGPJWer+Tc/bnFPxdD4Wp5XP0Y=; b=Sv8bpamjPQGUZQ5sh9ksoma1v5T1/PYF/ndiXbX+Wjr9nE62rLM2dQ0so+yXVXVPb6 fdgdJa1H9D6QfYObT8EqphCsdPfuR+4qKBq0NzBeOKpZg6HzZ3AB6Z315ag/xCjL6EwU ABMjrXJT1noz1lxCdvzGMOIptaEpJ2EWKKKH/XDISACq50MbH/sdwaVfiG7ZsqRRGesm wK9bMX89C8RicFfDslwOAQv9+e3Pj2iOe0f/giMd9OzPkeoiJzQMxBfG4nMarCDN4vv4 11ew/WncA8CFgwHy68DEEQidz818+P+JXrZqpKAihKXGIwMJND2QoFE0zh8IA2XnbIl9 Zwvg== X-Forwarded-Encrypted: i=1; AJvYcCVBDu5U2/EsYbIMhj4HI/3vt2PSHoeR4/8srU9hkVGkllpEUzYxiS79f5C5/D7lmp3XtSU5ou006uzzXSw=@vger.kernel.org X-Gm-Message-State: AOJu0Yzji5tcojJZRJgqEpcOgmsHClFEXRC/hvCnpdZXtZM0VLDq4jHP HDflDu7SQiL78YXCUizk3AgpXHzepm6Ia+fgBt+14dTOu10ci5kdwckdEHeKIQ== X-Gm-Gg: AY/fxX6TYscPvCkOcUCeCxJYWWMsCfjLNE0/Ml7uhATyNpisvTp2JoLx56BySD+LxFu pNW/yRcS4H19tCwrag2KtF2Z58g9C0ndutr2d3oAHl4x7wc0wMiYC0rXt76LfyG1RiLV6QrRvQe 5Oq6edVWNTnIDM6hA5BpSl70cZqCfPcFEG83CdX0HUmlYBVP3bVF8/biS+efmZJlwZbYmEacCmx im1ofvZorYwfTSqwoTX+Lkmjol6eOhP0kPvCvqFoe34AMvLeeAPc/G7wbFg1sDq+cpXVIW534Vz YOF4t5ope/Aj439nPX/MPWSIIU8QofDa7mmZsScs6AWCscuUfgfFlrxA53cHxfdmEE0FuzmMinV Ow+ceXhYp+jKH2/Pvgtd33GraoaVwKJW+9cujqyWIJXLxEP7QypC389AiED2sijPJTXpxQmrdM1 f59w== X-Google-Smtp-Source: AGHT+IF3Z5kgxOEyZ8TlUQEufDwaKzpJsoPdOR1wRnbEP5UUX7ilO8guI8waAq1O8VB1kpQTu9fn1Q== X-Received: by 2002:a05:6a00:ab0d:b0:7e8:4433:8fa4 with SMTP id d2e1a72fcca58-7ff6607e208mr29157334b3a.44.1767149730562; Tue, 30 Dec 2025 18:55:30 -0800 (PST) Received: from celestia ([69.9.135.12]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7ff7e892926sm33623646b3a.66.2025.12.30.18.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Dec 2025 18:55:30 -0800 (PST) From: Sam Edwards X-Google-Original-From: Sam Edwards To: Xiubo Li , Ilya Dryomov Cc: Viacheslav Dubeyko , Christian Brauner , Milind Changire , Jeff Layton , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Sam Edwards , stable@vger.kernel.org Subject: [PATCH 3/5] ceph: Free page array when ceph_submit_write fails Date: Tue, 30 Dec 2025 18:43:14 -0800 Message-ID: <20251231024316.4643-4-CFSworks@gmail.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251231024316.4643-1-CFSworks@gmail.com> References: <20251231024316.4643-1-CFSworks@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If `locked_pages` is zero, the page array must not be allocated: ceph_process_folio_batch() uses `locked_pages` to decide when to allocate `pages`, and redundant allocations trigger ceph_allocate_page_array()'s BUG_ON(), resulting in a worker oops (and writeback stall) or even a kernel panic. Consequently, the main loop in ceph_writepages_start() assumes that the lifetime of `pages` is confined to a single iteration. The ceph_submit_write() function claims ownership of the page array on success. But failures only redirty/unlock the pages and fail to free the array, making the failure case in ceph_submit_write() fatal. Free the page array in ceph_submit_write()'s error-handling 'if' block so that the caller's invariant (that the array does not outlive the iteration) is maintained unconditionally, allowing failures in ceph_submit_write() to be recoverable as originally intended. Fixes: 1551ec61dc55 ("ceph: introduce ceph_submit_write() method") Cc: stable@vger.kernel.org Signed-off-by: Sam Edwards --- fs/ceph/addr.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 2b722916fb9b..91cc43950162 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1466,6 +1466,13 @@ int ceph_submit_write(struct address_space *mapping, unlock_page(page); } =20 + if (ceph_wbc->from_pool) { + mempool_free(ceph_wbc->pages, ceph_wb_pagevec_pool); + ceph_wbc->from_pool =3D false; + } else + kfree(ceph_wbc->pages); + ceph_wbc->pages =3D NULL; + ceph_osdc_put_request(req); return -EIO; } --=20 2.51.2 From nobody Sat Feb 7 08:43:02 2026 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 536182E5D32 for ; Wed, 31 Dec 2025 02:55:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767149734; cv=none; b=aLPnq3MWGlaEMiul6mMEW5ImgKSyLJzqvSPbKIiJSj52iPC1vHYYRNukQQmLa4YWv5YJjgGfwonfJCY/nkmngLqmrVXGFJmUym0C70CrYMtgi8FHDRyOtKGq13z/m57j7bC/O2SGWzdLa4ZtysPp8+sJmLTd8dXMyrlFiaWaeS4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767149734; c=relaxed/simple; bh=7x51uiDaTktolV+LzMU7zA0PjIHxRzwQBudHNGCpDGg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SJWIsRPFOadbvqGrqdfim2LyZd2XdEkxPddUcELvAYzYT6d9lkMmY2F9yRgDimKs35uxOJIEshMkrD3HZjXwFU5F2bREJ+mPEn2iv1sjt9Cg4+Tw2BLpIJgXLXFnddBe64HNe8IcimguM4J1ImBYxzParyJKO10+ENUG9pCaaAw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eEe7MnOq; arc=none smtp.client-ip=209.85.210.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eEe7MnOq" Received: by mail-pf1-f195.google.com with SMTP id d2e1a72fcca58-803474aaa8bso3777203b3a.0 for ; Tue, 30 Dec 2025 18:55:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767149732; x=1767754532; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A6vlMYfzzrfVusqphG0GGHNwZxDj4Zq+5OFoT9T7pH0=; b=eEe7MnOq6VCPR+jJTNEjh4SyGDDkWRbtjjaHtchvBt0hBh+UAfPA8KiyEdOdzwnt7h yQsakuVbZl878/FoDsuSZSpjCkumIWYr2s+ALH4k2oGktfmGv76ErQG5akDa6nWKo18+ 0YwBZ0ya706JZk5H762V2EEiF0hpdl5eqaCfcEAjYD2FSvNN6FH/ae1PYZpE87TOMK3l e5/t0qV8zwtihC6wxe1xzQwuRXY7D+TGvFwLrEK1SIiN5CUE9cVOP48ChUGyObF6jfwM Uw7hKamidCfyfd45Ztb8KHMk8QKQLWBB3DCrFxQfu5e756MWRKMCC67jt78TPP9P08O7 TqvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767149732; x=1767754532; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=A6vlMYfzzrfVusqphG0GGHNwZxDj4Zq+5OFoT9T7pH0=; b=tDF9gUT82LzuCxvE7Sub2PvMStMUePrzrbKv3dodM3xxezjDCEXlZRKy2iw6czuSaQ W+tady9axPwkd5bANRh8KrdLQZKZPxXj4xxV32nfU3HviuflmenVWoVGUthpCDmZFM3Z IvxtJmwdaudQcw3O9IB/161PMRD9zH+jT7dw6L9iIjsOkCaN+Dcg+c2li4byYXxWAITH szOI5iID43xk6E+lA8njIIESTOROgUkw6fa52B5+kzfwUekIa3VzTp9mT7wnVHJhijWY Wnw158I+dYjqU1b7moi190AIG50YoQR+woPc83VCenXXqvi7Y1oHZxQeS3OzLm5sfNrF B86A== X-Forwarded-Encrypted: i=1; AJvYcCXhp1y7e/wteRNCaLaQ4vfWjaUirOylTYrjMVZ5gnDC6u8VMrOSD7se9LdsMM3LfffRaWRGROzStYzfXc8=@vger.kernel.org X-Gm-Message-State: AOJu0YyOBrAtH0siP/AJGR0qZMuEl/DhjwnZWPldNjvYIY92D/Vuu0iy 60LkXocLXe29rbWEUkBOU4dpYK4+PYxjReWLPBK2zXMTxImayR0KkIlT X-Gm-Gg: AY/fxX45G7FO/c9CilA1YMY3eMqK4X+OMqqfRifiyD76ZPUVHHM6GAmjvo9podcVLHn vbKu4gzsY7jBT4qe0+4fwDTkwwEnK22GKRM7njj6icRq/B8NbI4EdRYjxnVtnb9i8AxABIpFQ64 apyv5S1yCj7v0pKq0p2poW26pQEkCQGPDWYz3Sz6GQ9vLhIgw8kTv42LxXRpsbNYxouDCRtcrqG hmJd1fxWMEtNxJm1T+Nen02ClHrwfLwU1+jAHyYQPGwPmoXzqtx8ghgrNkokGcaHmL+6BV3t2MI 6aGtnPjq3/bGJlas4vjjF5QPRt2HClP+FygSKRAMRhU0NBfn+f2/lkSFG31voUomntl43o6OkGk fUOEaNAXi1/Z/7jCctl40aVp9x6vf77IZeGMX1Lldz1J7auuAh0asV0XXldQUEgp9V6xXc8tM+Z M+LQ== X-Google-Smtp-Source: AGHT+IEbU2+Y00aMWNdc38w4hjHwqdRtFca243nmnZxlmhfr5urwXm9ogf2dF3svZ9Qb+AeuG4fIeg== X-Received: by 2002:a05:6a00:4514:b0:78a:f6be:74f2 with SMTP id d2e1a72fcca58-7ff5284da68mr35782590b3a.5.1767149731611; Tue, 30 Dec 2025 18:55:31 -0800 (PST) Received: from celestia ([69.9.135.12]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7ff7e892926sm33623646b3a.66.2025.12.30.18.55.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Dec 2025 18:55:31 -0800 (PST) From: Sam Edwards X-Google-Original-From: Sam Edwards To: Xiubo Li , Ilya Dryomov Cc: Viacheslav Dubeyko , Christian Brauner , Milind Changire , Jeff Layton , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Sam Edwards Subject: [PATCH 4/5] ceph: Assert writeback loop invariants Date: Tue, 30 Dec 2025 18:43:15 -0800 Message-ID: <20251231024316.4643-5-CFSworks@gmail.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251231024316.4643-1-CFSworks@gmail.com> References: <20251231024316.4643-1-CFSworks@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If `locked_pages` is zero, the page array must not be allocated: ceph_process_folio_batch() uses `locked_pages` to decide when to allocate `pages`, and redundant allocations trigger ceph_allocate_page_array()'s BUG_ON(), resulting in a worker oops (and writeback stall) or even a kernel panic. Consequently, the main loop in ceph_writepages_start() assumes that the lifetime of `pages` is confined to a single iteration. This expectation is currently not clear enough, as evidenced by the previous two patches which fix oopses caused by `pages` persisting into the next loop iteration. Use an explicit BUG_ON() at the top of the loop to assert the loop's preexisting expectation that `pages` is cleaned up by the previous iteration. Because this is closely tied to `locked_pages`, also make it the previous iteration's responsibility to guarantee its reset, and verify with a second new BUG_ON() instead of handling (and masking) failures to do so. Signed-off-by: Sam Edwards --- fs/ceph/addr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 91cc43950162..b3569d44d510 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1669,7 +1669,9 @@ static int ceph_writepages_start(struct address_space= *mapping, tag_pages_for_writeback(mapping, ceph_wbc.index, ceph_wbc.end); =20 while (!has_writeback_done(&ceph_wbc)) { - ceph_wbc.locked_pages =3D 0; + BUG_ON(ceph_wbc.locked_pages); + BUG_ON(ceph_wbc.pages); + ceph_wbc.max_pages =3D ceph_wbc.wsize >> PAGE_SHIFT; =20 get_more_pages: @@ -1703,11 +1705,10 @@ static int ceph_writepages_start(struct address_spa= ce *mapping, } =20 rc =3D ceph_submit_write(mapping, wbc, &ceph_wbc); - if (rc) - goto release_folios; - ceph_wbc.locked_pages =3D 0; ceph_wbc.strip_unit_end =3D 0; + if (rc) + goto release_folios; =20 if (folio_batch_count(&ceph_wbc.fbatch) > 0) { ceph_wbc.nr_folios =3D --=20 2.51.2 From nobody Sat Feb 7 08:43:02 2026 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57F5E2E7F20 for ; Wed, 31 Dec 2025 02:55:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767149735; cv=none; b=lU+wJ3R+gOf+C3c4ZxjVQbZy1zXHeJoYw+LPfm4jQn4ciHd/KlFGhtE+bCJya1Pl5RUUuJkXhQAYKXvXzYOIbv2HujfH6sp1jX4AtCZqQvmE8sVugl2gTpw21KlSfoopz+pjBb8z2uWvPakjC7cp9SuUah1i8axWBTHbnCPYjZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767149735; c=relaxed/simple; bh=ZDstEKMD7WmKxZZCLmwJ/YSTgZ+JJejC8hgxByR/0Qk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=COX3HIqTgMZLrweHimaYQz+KLLvVlqIQvJcuhXf/hd/kiBgSCSNBuxgTthWcBwEXKByFXsKIO1yCmjH0cgxcSwz1NHGYAdgOkRX22tI6rBYjtSRf/A6s/1b0RnzijYhmJjx65bfXLYI05OLZ5gpOrKtaFx3Q8KtrbyfzoCwbkKU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=c09rU1ii; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c09rU1ii" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-7f651586be1so4991814b3a.1 for ; Tue, 30 Dec 2025 18:55:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767149733; x=1767754533; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mHQgO64N0mSOshA8/jcIaTzSFR+k9jE4B9vdvYmYNSA=; b=c09rU1iiRIUXGYCG+xJjTF/72ONz3lxVQWa1Cu5JmKGKTpNKxS05RLVd4/BbA/mZg8 rWJdzmu3QGd5Nq5UMThcVlBk+/ES9d3U2ffpjcmBezEqXt4fUYApXh9hshsgC+R+yURd 8KlwQuSGHunMeePGhaZfKUFnWv4bvHmod2NlP7nxQ9eKn+zTC2/d9V0y+LAhh0f1QHZ1 6Js1DSLhfM4LRVyrdiEocPlFZbioggMqsCfzajAChbu+5GGcPKO3rDQYOaNpuJKxiuIv oUwDnlnOjNz56pxCEPL8T6IluM/0FqkE5FoZtfgrFIv30qPeCbSTBqEA3ef3XkuWGOtc woBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767149733; x=1767754533; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mHQgO64N0mSOshA8/jcIaTzSFR+k9jE4B9vdvYmYNSA=; b=LQPW4A1D+IYAbmGSpiC+2VnxBRX4c2qPh5sHxsxx2zp3BbOYFESq4vS12P8bEYWMXF z3UOGS7Gcs7RC/BuFHflAxVIvuG47S0dEiEnkcBuQ+LnOKl9LE4ufINgVJXzS4e57Tyi gI4Ua/qbMlYUKth5Emfk6Fd9N7+KQy6DZ1dtZxhrxlN9tUMHeNwI+nu34GaZyeXfju2+ aWlKXfeKnN6OY7A50Fc3llaSDpCi3LtNZxhYPBp5rB6shyIG+I6lmP401BH72ApnXtKr 5iwH0LqVoeBzkyMrLirijUFuVhoZopwo0Gn++wMv0K9og6HzzDYNzAb+dMU91nKsyuvF PGZA== X-Forwarded-Encrypted: i=1; AJvYcCXLfolrHdEUqhheBv5w3iN4NwlDwai0JNE9N2L3rA8Z5H0OELrjF7Y+0kIfCDd7LCBsRFC/1MErlamdyTY=@vger.kernel.org X-Gm-Message-State: AOJu0Yyu3UnaRoZWq4b9N/IwnIltmQByiGXCRWHP3cak9APnrsUvAoDB WxBQ+/d4CPXMvewl4Hk9K+ass3thdNum67/GZKTlFX2uGKhso5Jui0ft X-Gm-Gg: AY/fxX4iQrm4pmHrk2au/tXk4D/8YyspL5W8KUId27vJmrezXHH1S8KMD8qSkFbBkmb VvLIQtvWWa+8cex3Fe2hLsc1byY6ATjf03fQcw+iyNlPQJeeE3XBQ2M/t2z/nSNUXyEtMbooJxr jIzlWyhaMZdiK1v6ahNnjNO0NJ61DYceSEKXzWJBmp+v3hcpgA3frPcVonL77GYYCFJ+wBtoFt4 HnbVK0sAusgIjCK0ux+ZwBsHMUKc+ezIqiJpAzohtSPyy4Sq1/IGH+99p2j6tXbs8YnVQRQzuYK J78obOgZg2IKLtgk8WPofvREf85CLBmCKd96ZcrRqRmST7/emm4VuK7vWON+OWGfywL5PA7Qnju hZ/9o218eVARehlUJva327R7z4id5axcK83HARCOIb6BcV6LuP2ub5qNKE0NTKwpIV8gzcGeRw0 uozUlG5lG8Mgvw X-Google-Smtp-Source: AGHT+IE/6+hfXayWM1JdWA9o6vJZIBu0G6SoALMz31yXzlT5yBq/IAL6FIfaJeCzxB1pm8U2r9/1vQ== X-Received: by 2002:a05:6a00:8e02:b0:7b8:8d43:fcde with SMTP id d2e1a72fcca58-7ff52d3852cmr33628015b3a.8.1767149732685; Tue, 30 Dec 2025 18:55:32 -0800 (PST) Received: from celestia ([69.9.135.12]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7ff7e892926sm33623646b3a.66.2025.12.30.18.55.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Dec 2025 18:55:32 -0800 (PST) From: Sam Edwards X-Google-Original-From: Sam Edwards To: Xiubo Li , Ilya Dryomov Cc: Viacheslav Dubeyko , Christian Brauner , Milind Changire , Jeff Layton , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Sam Edwards , stable@vger.kernel.org Subject: [PATCH 5/5] ceph: Fix write storm on fscrypted files Date: Tue, 30 Dec 2025 18:43:16 -0800 Message-ID: <20251231024316.4643-6-CFSworks@gmail.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251231024316.4643-1-CFSworks@gmail.com> References: <20251231024316.4643-1-CFSworks@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" CephFS stores file data across multiple RADOS objects. An object is the atomic unit of storage, so the writeback code must clean only folios that belong to the same object with each OSD request. CephFS also supports RAID0-style striping of file contents: if enabled, each object stores multiple unbroken "stripe units" covering different portions of the file; if disabled, a "stripe unit" is simply the whole object. The stripe unit is (usually) reported as the inode's block size. Though the writeback logic could, in principle, lock all dirty folios belonging to the same object, its current design is to lock only a single stripe unit at a time. Ever since this code was first written, it has determined this size by checking the inode's block size. However, the relatively-new fscrypt support needed to reduce the block size for encrypted inodes to the crypto block size (see 'fixes' commit), which causes an unnecessarily high number of write operations (~1024x as many, with 4MiB objects) and grossly degraded performance. Fix this (and clarify intent) by using i_layout.stripe_unit directly in ceph_define_write_size() so that encrypted inodes are written back with the same number of operations as if they were unencrypted. Fixes: 94af0470924c ("ceph: add some fscrypt guardrails") Cc: stable@vger.kernel.org Signed-off-by: Sam Edwards --- fs/ceph/addr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index b3569d44d510..cb1da8e27c2b 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1000,7 +1000,8 @@ unsigned int ceph_define_write_size(struct address_sp= ace *mapping) { struct inode *inode =3D mapping->host; struct ceph_fs_client *fsc =3D ceph_inode_to_fs_client(inode); - unsigned int wsize =3D i_blocksize(inode); + struct ceph_inode_info *ci =3D ceph_inode(inode); + unsigned int wsize =3D ci->i_layout.stripe_unit; =20 if (fsc->mount_options->wsize < wsize) wsize =3D fsc->mount_options->wsize; --=20 2.51.2