From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (unknown [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 4D0808017D for ; Fri, 18 Sep 2026 10:27:27 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 68IAQ9R3032292; Fri, 18 Sep 2026 13:26:09 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 68IAQ9R3032292 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="sJ5PPrXp" Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 68IAQ7BZ032288 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Fri, 18 Sep 2026 13:26:07 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 68IAQ7BZ032288 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-486f768517dso474639f8f.1 for ; Fri, 18 Sep 2026 03:26:07 -0700 (PDT) X-Gm-Message-State: AFuF++nCepNVQwQoY/6kzQhSJfPvNy80UayFA8WOnpXYJlEa3Mq5Kgd6 JjpixoEORgb3xJU58U6Pljzpn8nr5hD9HltFFghH1st4iqjZ6e4v1z8P2LG2TQcKcwHEbJErewA lJHVR7NCYXZ6av5ItWzfel2fBh2JeoOCuggz9nysH39SwFZlGCQIPMw== X-Gm-Gg: AYBFou3+TOLu21zyF1bEwllQpK4Twbgsv8l/iV2KAQGIJRXxIS8flZkV2Hk7TDlThrC 5jUijoh05m/DhPveDsWhhz9BxkWjL/Bd1exNDDiP5+UdVzaEZRpHsueMdplpuJ+Oz2xvV5xRaK2 iA3KfOwBiGiiPFdwydKPk2je8fZyY0k49UgNAT9guZQm+QRzYeDczixE4AR1s9ljaq2Rq0pSSeO FCKqkEOr7OlY2pW0ItkkHG+Mr4mYBvho58wz8as8H6bR/77n+n8YudxfKGLg1OVBNygi8HD/OVq r6TZoM8Men82eA6s3GdCOHbByL6Mtilf7fCfMBIGv5HEbBGTGl15F7N9XzqW7Zd3NlVB7hYjxWN 8EM5vuQWm9VcpNNY= X-Received: by 2002:a05:6000:4610:b0:487:62d:37d6 with SMTP id ffacd0b85a97d-4871e37b999mr5156138f8f.23.1789727165933; Fri, 18 Sep 2026 03:26:05 -0700 (PDT) X-Received: by 2002:a05:6000:4610:b0:487:62d:37d6 with SMTP id ffacd0b85a97d-4871e37b999mr5156021f8f.23.1789727165341; Fri, 18 Sep 2026 03:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1789727165; cv=none; d=google.com; s=arc-20260327; b=j0BUZaDtoBlbUkdHFetZhj3B2DR/FDDTaTmhN4tQdG2SwhLhsbUrBvZREPUKZ+Uyf7 tvwIFnpmaQkoUElO3RmKOkImV1wzLMkwIKQLtxIJQqQj2WbQvJ30WFMym4uoRhT68+Im lP4FXlg0KdhVXj5ze8NArU72HwWtxUswfWSAR4CEETIXs6SeqfGCgoCw37t3Y8tPbCjf 1QlrhhqlhWDsDZ/OoaITBYJq6cMBlltfrEhbI4a2iG5zVmSREkRj3Zu0TroxqweSdpd9 s3ghrQ4OlgIQnxHh1PfGQc/bHbBjIY3udO61OjuAKL19HbiGJmHK+nuO5kVLuteMUUkY rw6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:dkim-signature; bh=sDIv+igUlo4l0TwdtFB8cRdFgu1yTVidAmHgFMXkOds=; fh=6JpqpGxFeFNaDh+k4t2UfZyo3rKe/54dyQ52T8vVmSc=; b=ke7JAnZUk7Ms59MtUmc7gOspabJ2WjYW1hrbmcCBjbmEXhj1XkzKw7Y6/zmk/pEzAK WYUpF9Xoq29cxMuT2ARfHddN5w2DVHVoQc+nyXTPGLVQ+UBRRuIEo8k9Mt86ll/00+1q 8E/Vvcou8BIg9Wu/F26CVUSBrS0BMOERP9kG6+2lu/KHHTojt6CVEPkOaEeJbyEKzknT uobFEYZcA928c1xD0eWIRhLFULyJ9G221j6coh0thwfU27KaPalL6fLn01ut3tMOjFlR c+/9lH/wj3RUrAoqkW6Aw5r/FksUYtMdI9P6SFB+vCnyUXBa2GQWsMcc22Eh3IUjbGWa MQhw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=sJ5PPrXp; spf=pass (google.com: domain of kui.liu@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=kui.liu@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-48720099009si1977487f8f.153.2026.09.18.03.26.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2026 03:26:05 -0700 (PDT) Received-SPF: pass (google.com: domain of kui.liu@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=sJ5PPrXp; spf=pass (google.com: domain of kui.liu@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=kui.liu@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Message-Id:Content-Type:MIME-Version:Subject:Date :From; bh=sDIv+igUlo4l0TwdtFB8cRdFgu1yTVidAmHgFMXkOds=; b=sJ5PPrXpU18BsQbpk8m YOAvcZwHBCuzTHjhPEJFCQwdjwq3xSlYsxTbSW0clH0NsvWdCy3S/UJvpOL0Rd38LymUrtcpDDbzM d67gfa6tI1ndO3pezL996Cytb3e4w2IcGUEokdLw0MoeUrTbFOlo1x0ZTTkHe9WqnvqvuAV7QrRnV /mQmu02vpkeHkMtRQv8EiM/Oc+2qJSglk51mZQq/56Ka78Brua/y/xe0mQzsIJEqxLqGjJCvCvu3A TrAc+AcSJEEJmGVeAgglE9a+9pZG+7xmnahQu6VxqSP8EnincCONR039bi69JDpZit0wOeQ9F1Q82 qOc03E30EgaChtQ==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=LK-MBP.local) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1x7VkN-003DN6-0c; Fri, 18 Sep 2026 12:26:01 +0200 From: Liu Kui Date: Fri, 18 Sep 2026 18:25:41 +0800 MIME-Version: 1.0 Message-Id: <20260918-vstor-145614-writectr-v1-1-588a9eff3aa3@virtuozzo.com> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/yWMQQ6CMBAAv0L27Jq2QkG/YjzQush6ALNb0YTwd 1c9TiYzKygJk8KpWkFoYeV5MvC7CvLYTzdCvhpDcCG6o+9w0TIL+rqJvsaXcKFcjNvUD/EQqEk tWPsQGvj9+55hzIzd3sHlL/SZ7hZ9r7BtH0bQFJaCAAAA X-Change-ID: 20260918-vstor-145614-writectr-17baf632e5b7 To: Konstantin Khorenko X-Mailer: b4 0.16.0 X-OZ-Fwd: true Cc: azaitsev@virtuozzo.com, devel@openvz.org, Liu Kui Subject: [Devel] [PATCH hci-8.0] fs/fuse: fix writectr imbalance when failing writeback of invalidated file X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org The shoot-on-sight path in fuse_writepages_send() for files being invalidated violates the writectr protocol: the increment is not gated on writectr >=0, and the matching decrement lives in a separate fi->lock critical section. A concurrent fuse_set_nowrite() and fuse_release_nowrite() pair lands in that window observes writectr == FUSE_NOWRITE + 1 and triggers BUG_ON(fi->writectr != FUSE_NOWRITE) in __fuse_release_nowrite(): kernel BUG at fs/fuse/dir.c:1842! RIP: fuse_release_nowrite+0x45/0x50 [fuse] fuse_release+0xd0/0x300 [fuse] __fput+0xe1/0x2a0 __x64_sys_close+0x3c/0x80 Fix it by always routing writeback through fi->queued_writes so the writectr gating applies, and failing requests on invalidated files in fuse_send_writepage() instead, where the existing out_free path keeps the writectr increment and decrement balanced within a single fi->lock critical section. Note that if a NOWRITE section is active, queue the request instead of failing it immediately is harmless for the file invalidation operation. https://virtuozzo.atlassian.net/browse/VSTOR-145614 Signed-off-by: Liu Kui --- Fix a writectr protocol violation in the shoot-on-sight writeback path for invalidated files, which races with fuse_set_nowrite()/ fuse_release_nowrite() and triggers BUG_ON(fi->writectr != FUSE_NOWRITE) in __fuse_release_nowrite() (vmcore analysis in VSTOR-145614). https://virtuozzo.atlassian.net/browse/VSTOR-145614 --- fs/fuse/file.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index c96a631b9529..180f60fc539a 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2237,6 +2237,11 @@ __acquires(fi->lock) int err; fi->writectr++; + if (fuse_file_fail_immediately(wpa->ia.ff)) { + /* File is under invalidation: fail request without sending */ + mapping_set_error(wpa->inode->i_mapping, -EIO); + goto out_free; + } if (inarg->offset + data_size <= size) { inarg->size = data_size; } else if (inarg->offset < size) { @@ -2619,28 +2624,17 @@ static void fuse_writepages_send(struct fuse_fill_wb_data *data) { struct fuse_writepage_args *wpa = data->wpa; struct inode *inode = data->inode; - struct fuse_mount *fm = get_fuse_mount(inode); struct fuse_inode *fi = get_fuse_inode(inode); int num_pages = wpa->ia.ap.num_pages; - struct fuse_args *args = &wpa->ia.ap.args; - int shoot_on_sight = 0; int i; spin_lock(&fi->lock); - if (fuse_file_fail_immediately(data->ff)) { - shoot_on_sight = 1; - fi->writectr++; - } else { - list_add_tail(&wpa->queue_entry, &fi->queued_writes); - fuse_flush_writepages(inode); - } + list_add_tail(&wpa->queue_entry, &fi->queued_writes); + fuse_flush_writepages(inode); spin_unlock(&fi->lock); for (i = 0; i < num_pages; i++) end_page_writeback(data->orig_pages[i]); - - if (shoot_on_sight) - args->end(fm, args, -EIO); } /* --- base-commit: 397370a45ebb33b582fe6e5c0b2240cc4edb7bc9 change-id: 20260918-vstor-145614-writectr-17baf632e5b7 Best regards, -- Liu Kui _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel