From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 D739F370D63 for ; Wed, 12 Aug 2026 20:49:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786567768; cv=none; b=QiXU6di50X054NwrXl/Riaz9hvR++dDkEqDBTcEKsiB7hNTijFaEEgDwAQD8Gc7/phPS3oteWBgT2O0HtQ9G8qxbJFRCcWcPt53ZNka0EsCPELAo/BKAU9mJhJl40I15KgR5W3XeTmFXzGMheReK2mQPsUSWcS+LHksTFlyPMAw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786567768; c=relaxed/simple; bh=S2/IKQBe3BZ2BJZDm8nE1WDqx5CW6h0/h3hRPhM6Tnw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=aeyOPVJkjR43Ts1Ctj/stg9j3VMBIXMb0U4rfjp/b4Kvj7J44I1D/GYcVFwnEhildj56DITr1Y4jBQBE0KiDXhZHJ/MubwovkzHGmb8JCfQWDB+qlRasnNZEaQeg0s1PpeW4+YhBVNptdmc+S8T0PpuFfLuMsw8psMK4kn8+V4A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=ZI9KpFbj; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="ZI9KpFbj" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-49802c418b5so13424615e9.1 for ; Wed, 12 Aug 2026 13:49:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1786567764; x=1787172564; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=5Bl0riAnOz4MDPzNl0/YTiH6hc1BXf4s2D9tpakXXVs=; b=ZI9KpFbjd54rjBp4TDVw1bS55FJhsjNLS/4OHPzDswqT/uW4/knmamWFB4OfyXqRIw hrhzqWNKdDScgW7SG6Sm2Cx+FGRGk7oM/+zoU8fCwrYqR/g+kMt4cE/skME9rQ+mhDxl tiiN+7AFffqUcBFsjQ5Xa935vIx4NgUC/sfEI7iNMdSOM84XaNRP4x+BEV7uHIm3pIwo D7aLZpklT1g8XNs8Oq2TwshfBFbal2k5VDpMqPwagrvXMwTyVd9JGfU7hT3h6tCN6OyM ekEfVvTeOpeLA7sq3kY7bNqOrfM4UCQjdpoj+WCLScSND4Whf8X/+DxdVuyfWdlfWTJ5 geCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786567764; x=1787172564; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=5Bl0riAnOz4MDPzNl0/YTiH6hc1BXf4s2D9tpakXXVs=; b=RlAD9cIwaeeQdVjyPS740MZhHk15fN5iE9OolxMRJPp9RLuz5ZOaPwEAqqgCkIQHxD RpZyPYUKP0S8IaxArYaSV7jVgbUQ6fA3y7jeO+sHFJy/gHctvUW0r+l29tm5r0WioPmD k+gafbgJS/d3Lizq0bP1jp8O/Mtwjzt6HcU/hu0oBzmaj0z9VXWl8WIEjy5J8gB5KmKW 9kR4v2BgvCsnMfu/ZX1n6r2fcPET3yFrINQlYsnqeooRfsySLQ63CSk3QFRGDokEgguL TYHZ+t7Ghz4BXvt4IxYv6kpLRkv3Gq/M+x2zXxk/moCtWPjzZ1Q4f5f3qCJ0yZjqVB9M ov0A== X-Forwarded-Encrypted: i=1; AHgh+RryrV5yDn7ZcIrdq/Uk2yXedkN3gtv8kuuhn4AK4OLddWv98t0J7SElbrha8FnPbOxCq66zM0zLxFJPzdc=@vger.kernel.org X-Gm-Message-State: AOJu0YzNShxsEpwD2jQGn8xesamHMrQ3Idsr2uq5HwMbMcDrsBYlxo7V G8OzSmPy1DgnE3TmanQC6sKFa6FkNtBMpfb9D3YB2HPnZvX7IGHr9ZjEs4aC2BBjEGo= X-Gm-Gg: AR+sD11USJe53p1iGC8kSkf3vxOJDNFt/m7sXnov5elx/loKRVqZdx13ODqG07aXR81 73MDKIDb0orm6wouRUqbJdwkY2S9iV8vnuMvFHjfVJ1LdSjWPyGb0207WXL0zIkNv2ExIbq7QZQ r4/NOum306Wb/f4TCQ+USxJmx0LK8Ptm/CopC2WaH9aPp90isHEaDkM98DUjGcOC9JH/LVfTo2t Zu785IPwC3zynEMXmaClCCdGFl+k0wYWl6QFCs+/h39GaGbT/8GXP84c5XRh7R8Q6OrZ6rHRJp9 awDcX4fjWgW0sXbpMYKmEwxYB5J9EUWHVVZew85PojUEHfVv51McapKtRV7b2R7OuHx/dm4sR0A ri2eAC33V+3eMi4Q2Uf++7vljEO7v9T/CGPiasoPr+q7ZzsAcH9drjczJMfQFaIejBm2KZVJWu+ z02G6vvcX6g/FINA7/F1197SYu4FyVd9zPEMzg4BUmOSqtmWChL4eJ3dSnlNIjGNq1dbUsw4sDX EuWbPwmpdr708S8x6rCpmticoj4b1JJlSTQiO50HZJ7qs2UJ8FJrOVrSwgqF3gWrhfrF9nSIus= X-Received: by 2002:a05:600c:8010:b0:495:4749:16a7 with SMTP id 5b1f17b1804b1-499821d2047mr3066305e9.14.1786567763997; Wed, 12 Aug 2026 13:49:23 -0700 (PDT) Received: from raven.intern.cm-ag (p200300dc6f02b200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f02:b200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49981d85953sm7766555e9.0.2026.08.12.13.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2026 13:49:23 -0700 (PDT) From: Max Kellermann To: idryomov@gmail.com, amarkuze@redhat.com, xiubo.li@clyso.com, ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v2] fs/ceph/super: document struct ceph_dentry_info and its flags Date: Wed, 12 Aug 2026 22:49:20 +0200 Message-ID: <20260812204920.1805545-1-max.kellermann@ionos.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Signed-off-by: Max Kellermann --- v1->v2: two corrections --- fs/ceph/super.h | 122 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 119 insertions(+), 3 deletions(-) diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 1d6aab060780..169a440e984f 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -326,29 +326,145 @@ struct ceph_inode_xattr { int should_free_val; }; -/* - * Ceph dentry state +/** + * Ceph-specific dentry data (for `dentry.d_fsdata`). Call + * ceph_dentry() to obtain the #ceph_dentry_info pointer from a + * #dentry. */ struct ceph_dentry_info { + /** + * A pointer back to the #dentry owning this object. + */ struct dentry *dentry; + + /** + * The #ceph_mds_session that issued the lease; holds a + * reference that must be freed with ceph_put_mds_session(). + * May be NULL. + */ struct ceph_mds_session *lease_session; + + /** + * List hook; depending on the flags, it may be in + * ceph_mds_client.dentry_leases, + * ceph_mds_client.dentry_dir_leases or in + * __dentry_leases_walk().dispose (or in no list at all if + * this #list_head is empty). + */ struct list_head lease_list; + + /** + * Hook for `ceph_fs_client.async_unlink_conflict`, protected + * by `ceph_fs_client.async_unlink_conflict_lock`. + */ struct hlist_node hnode; + + /** + * Bit mask of CEPH_DENTRY_* + */ unsigned long flags; + + /** + * Snapshot of the parent directory's + * `ceph_inode_info.i_shared_gen` taken when this dentry was + * last validated against the directory lease. When the + * directory's `i_shared_gen` moves on, all cached dentries + * below it (including this one's #offset) are stale. + */ int lease_shared_gen; + + /** + * Snapshot of the issuing `ceph_mds_session.s_cap_gen` taken + * when the (single-dentry) lease was granted. The lease is + * only valid while this matches the session's current + * generation; a session reconnect bumps `s_cap_gen` and thus + * invalidates all of its leases. Zero means "no valid + * lease". + */ u32 lease_gen; + + /** + * The lease sequence number as received from the MDS + * (`ceph_mds_reply_lease.seq`). It is echoed back to the MDS + * in lease RENEW/REVOKE_ACK messages. + */ u32 lease_seq; - unsigned long lease_renew_after, lease_renew_from; + + /** + * Jiffies timestamp: the earliest time at which a proactive + * lease renewal should be initiated (roughly half the lease + * TTL). Zero while a renewal is already in flight (see + * #lease_renew_from). + */ + unsigned long lease_renew_after; + + /** + * Jiffies timestamp recorded when a lease renewal request was + * sent; the new TTL and #lease_renew_after are computed + * relative to it once the reply arrives. Zero when no + * renewal is pending. + */ + unsigned long lease_renew_from; + + /** + * Jiffies timestamp whose meaning depends on which lease this + * dentry holds: for a single-dentry lease it is the expiry + * time (TTL); for a directory lease it is when the dir lease + * was last touched (compared against + * `ceph_lease_walk_control.dir_lease_ttl`). + */ unsigned long time; + + /** + * This dentry's position (an encoded file position; see + * ceph_make_fpos()) within its parent directory's readdir + * stream, used to preserve readdir ordering when serving + * entries from cached dentries. Zero if unknown/invalid. + */ u64 offset; }; +/** + * Second-chance ("referenced") bit for the dentry-lease shrinker: set + * when an already-listed dentry is touched again, so the walker + * spares it for another round instead of disposing of it (a + * clock/LRU-style approximation). + */ #define CEPH_DENTRY_REFERENCED (1 << 0) + +/** + * `ceph_dentry_info.lease_list` is on the + * `ceph_mds_client.dentry_leases` list. + */ #define CEPH_DENTRY_LEASE_LIST (1 << 1) + +/** + * `ceph_dentry_info.lease_list` is on the + * __dentry_leases_walk().dispose list. + */ #define CEPH_DENTRY_SHRINK_LIST (1 << 2) + +/** + * This dentry is the primary link to its inode (as opposed to a + * remote/hard link). Reflected from #CEPH_LEASE_PRIMARY_LINK in the + * MDS lease mask. + */ #define CEPH_DENTRY_PRIMARY_LINK (1 << 3) + +/** + * An asynchronous unlink is in flight for this dentry. While set, + * the dentry is on the `ceph_fs_client.async_unlink_conflict` hash + * (via `ceph_dentry_info.hnode`); other operations on a conflicting + * name must wait for the bit to clear + * (ceph_wait_on_conflict_unlink()). + */ #define CEPH_DENTRY_ASYNC_UNLINK_BIT (4) #define CEPH_DENTRY_ASYNC_UNLINK (1 << CEPH_DENTRY_ASYNC_UNLINK_BIT) + +/** + * An asynchronous create is in flight for this dentry; waiters block + * on the bit until the create completes. + */ #define CEPH_DENTRY_ASYNC_CREATE_BIT (5) #define CEPH_DENTRY_ASYNC_CREATE (1 << CEPH_DENTRY_ASYNC_CREATE_BIT) -- 2.47.3