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 A40568017D for ; Wed, 30 Sep 2026 05:46:34 +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 68U5jAlT011500; Wed, 30 Sep 2026 08:45:11 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 68U5jAlT011500 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="mWLVuAOB" Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 68U5j8DE011492 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 30 Sep 2026 08:45:08 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 68U5j8DE011492 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4a004b70f99so16098255e9.2 for ; Tue, 29 Sep 2026 22:45:08 -0700 (PDT) X-Gm-Message-State: AFuF++nEswssY2YST6rG6dQJ16nqv3sAZ+K80gZEkuNcVn+11l79gJWs rST+/PqUVrjTxEmx3nasu5gwF9pfPpN3Q9r33e2C/d8KXHdbCIMop8EDL6iddR0ESbzfHUjqKoq W3413rTAxPhppsqoRfs3v2XmAAZDlLUZl6RJcdfw/4I1b0YRdy0ZiVA== X-Gm-Gg: AYBFou3AgkHh0TUIxk6bwwO4VoPhRqW7QlP2rfeVrqBwuDmSYYCAfVYGQYxb1s+W/xj 1LTidBmO9oHZ6KOKlCVglPE2QV9yK6oNNwq8JYPFOZCb8GbAXNA6t1B/wwyXSljMgSAxBeuNyXG 1CN94V97Mb+bduHBD1ybnhTXOatpXhlVrfyPfK049zpgNaM+NWxotUAaxrZZu6Dz47AK9zXRSu3 SIkwOydPLtXZrI9spLtLGu9nnt1iOvNq+Jx8687Lw0XkKNU0gOy6cuQ9hYw91Jr8XqgLSc7hvO+ JOqwxQp4i1bYHKGF1rkJtHZXNcSirzCGFa3sUgK0Q1t+hWjlx1LC7yhUxBla9of+yF1/n7hHPJH u+Q7yuxhK48v4pqo= X-Received: by 2002:a05:600c:4fc5:b0:49f:ddc0:6e8f with SMTP id 5b1f17b1804b1-4a01aff11b0mr2326145e9.5.1790747108128; Tue, 29 Sep 2026 22:45:08 -0700 (PDT) X-Received: by 2002:a05:600c:4fc5:b0:49f:ddc0:6e8f with SMTP id 5b1f17b1804b1-4a01aff11b0mr2325935e9.5.1790747107623; Tue, 29 Sep 2026 22:45:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1790747107; cv=none; d=google.com; s=arc-20260327; b=D9G6MMs59cIoPJNoxvV7BasrU11Fv8Y8o0r21yrW3Id4pylVJ5NI/GvMnbtWc9oRwS 6QoM1elwuT9bfLLH91Pmp/MwwIaKhELcld9SYlHZyDW6sEmHpjkRYiy4Ozpy8HvSjTP1 xVU6bD4zYwLJPpgoKy1OV9lIoIClunJQHcT1TixXTu78OT7qQXgU5SiSxg5EGFNSKEEj 36Qo2IbjeGG+D1mogyQOIo7xSHv5Ktn6sk5fUf3VzKosNxmzO5kry7+5d3yp8s77WYYv OYXDymReTInpIduICSDrdzMv79iI7QwXJ2nlxGZFGm7Q0JyfhVZAMLtnaFJYu5Slg2t8 rzzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=ga+kICw6SasXCa/fy7/dCzatkNsKNy/8cmz87BBF85U=; fh=6JpqpGxFeFNaDh+k4t2UfZyo3rKe/54dyQ52T8vVmSc=; b=i9oj0A9v2sDzuXxFqfCRKVF8+DoKHl7G/hmh9wMn7BXFCKAb5D8yqzRruu3xh1ASt3 MMY3nTs3emJOQaj5EPQrf8LEks1grXgStub6b954SqUObFtjM8LOfCLxUgsmEcbFFPG/ dSVj1tv4fuOgwoeh2ZPI0fwjgducmC1z0H/7rTSdZcFSWwyuecEu9mVv28vaN8DJIEDq EoMyTo7IU3AxNZrjmSFOcLvnps/axPt7h+PaSV3YgFA4ZKa8cuht0cAgEZqMP1FYQHN4 an1+Rk9bRmQ+vA5fMXpLjKh91F4ATSRPqDdCOZ1R+ZYMZ5cCiryknS3c3n46raYQlflV c4/A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=mWLVuAOB; 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-48b029c33desi468287f8f.91.2026.09.29.22.45.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2026 22:45:07 -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=mWLVuAOB; 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=ga+kICw6SasXCa/fy7/dCzatkNsKNy/8cmz87BBF85U=; b=mWLVuAOBgm4B9LFkywV IbVdKqkxVD0bN+w0GEdF0MgWO032Lke9sr2vueynwflasHJ8t8xjC7kK8jJOWlfBJT7kVJqW16uxr TmYiO5YyY/UeRhQ6l6R48zxsT5QO1XD69fsAZac2VtXgIlMcc6stM3nJ+x+hIKQX0TQ8+HDtDQdkv i07hQj0cOK+K6heEwP5u7mI44CMPM8G5O3W25rgINtQ5SA8AztN19EbDBgAyz1Kq9CvzuxbWh58zC 0eOzBWQBSiTjnf33eRO5gH39o660qd1xMS3QyrDUQMQTZxKLEu8/O7k1MrTV0e8Y6PoGRlVVchTar zRyS7CSnQyAbqJw==; 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 1xBn4l-00DrnK-1j; Wed, 30 Sep 2026 07:45:07 +0200 From: Liu Kui Date: Wed, 30 Sep 2026 13:44:48 +0800 MIME-Version: 1.0 Message-Id: <20260930-close-wait-rework-v2-v1-1-f8062178544a@virtuozzo.com> References: <20260930-close-wait-rework-v2-v1-0-f8062178544a@virtuozzo.com> In-Reply-To: <20260930-close-wait-rework-v2-v1-0-f8062178544a@virtuozzo.com> 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.1 1/3] fs/fuse: give num_openers and i_size_unstable each a single role 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 Currently fi->num_openers serves two purposes: it helps decide whether the i_size attribute needs to be taken from the server, and it manages when kio's file_open/file_close methods need to be called. The former role already requires the extra i_size_unstable flag to handle lease revokes, which makes num_openers redundant for that purpose. Give each field a single role: use i_size_unstable as the "take the attributes from the server" flag, and make num_openers a pure open count managing the calls of kio's file_open/file_close. A new inode starts with the i_size_unstable flag set, an open finding it set refreshes the attributes and clears it on success, and the last release sets it back after writeback has drained. Also fix a bug where a failed refresh could re-trust stale local attributes. https://virtuozzo.atlassian.net/browse/VSTOR-147878 Signed-off-by: Liu Kui --- fs/fuse/file.c | 21 ++++++++++++++++----- fs/fuse/fuse_i.h | 4 ++-- fs/fuse/inode.c | 5 +++-- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index e0efb524cda7..c41d6445c7e5 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -293,8 +293,14 @@ static int fuse_open_close_wait(struct inode *inode, struct file *file) inode_lock(inode); spin_lock(&fi->lock); - if (++fi->num_openers == 1 || fi->i_size_unstable) { - fi->i_size_unstable = 1; + fi->num_openers++; + /* + * i_size_unstable set means the attributes must be taken from the + * server: no open has refreshed them yet (first open), the last + * opener is gone, or the files were invalidated by a lease revoke. + * Refresh the attributes so ours can be trusted again. + */ + if (fi->i_size_unstable) { fi->inval_mask = ~0; spin_unlock(&fi->lock); err = fuse_update_attributes(inode, file, ~0); @@ -303,9 +309,10 @@ static int fuse_open_close_wait(struct inode *inode, struct file *file) err = fc->kio.op->file_open(file, inode); spin_lock(&fi->lock); - fi->i_size_unstable = 0; if (err) fi->num_openers--; + else + fi->i_size_unstable = 0; } file->f_mode |= FMODE_NOWAIT; @@ -583,8 +590,12 @@ static int fuse_release(struct inode *inode, struct file *file) wait_event(fi->page_waitq, refcount_read(&ff->count) == 1); spin_lock(&fi->lock); - /* since now we can trust userspace attr.size */ - fi->num_openers--; + /* + * Last opener is gone and its writeback has drained: from + * now on take the attributes from the server again. + */ + if (--fi->num_openers == 0) + fi->i_size_unstable = 1; spin_unlock(&fi->lock); } else if (fc->close_wait) wait_event(fi->page_waitq, refcount_read(&ff->count) == 1); diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 21f873337627..f6da643b9c86 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -200,10 +200,10 @@ struct fuse_inode { /** Reference to backing file in passthrough mode */ struct fuse_backing *fb; #endif - /** Mostly to detect very first open */ + /** Number of opens, drives kio file_open/file_close pairing */ int num_openers; - /** Even though num_openers>0, trust server i_size */ + /** Take attributes (i_size) from the server, don't trust ours */ int i_size_unstable; /** Private kdirect io context */ diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index eb2e9a4f8756..4eaa89d9c46c 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -116,7 +116,8 @@ static struct inode *fuse_alloc_inode(struct super_block *sb) fi->orig_ino = 0; fi->state = 0; fi->submount_lookup = NULL; - fi->i_size_unstable = 0; + /* take attributes from the server until the first open */ + fi->i_size_unstable = 1; fi->private = NULL; fi->inval_files_seq = 0; INIT_LIST_HEAD(&fi->rw_files); @@ -328,7 +329,7 @@ u32 fuse_get_cache_mask(struct inode *inode) if (fc->close_wait) { struct fuse_inode *fi = get_fuse_inode(inode); - if (!fi->num_openers || fi->i_size_unstable) + if (fi->i_size_unstable) return 0; } -- Git-155) _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel