Skip to content

Commit b2b4483

Browse files
osandovbrauner
authored andcommitted
dcache: convert dentry flag macros to enum
Commit 9748cb2 ("VFS: repack DENTRY_ flags.") changed the value of DCACHE_MOUNTED, which broke drgn's path_lookup() helper. drgn is forced to hard-code it because it's a macro, and macros aren't preserved in debugging information by default. Enums, on the other hand, are included in debugging information. Convert the DCACHE_* flag macros to an enum so that debugging tools like drgn and bpftrace can make use of them. Link: https://github.com/osandov/drgn/blob/2027d0fea84d74b835e77392f7040c2a333180c6/drgn/helpers/linux/fs.py#L43-L46 Signed-off-by: Omar Sandoval <osandov@fb.com> Link: https://lore.kernel.org/177665a082f048cf536b9cd6af467b3be6b6e6ed.1744141838.git.osandov@fb.com Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent a64e4d4 commit b2b4483

File tree

1 file changed

+50
-56
lines changed

1 file changed

+50
-56
lines changed

include/linux/dcache.h

Lines changed: 50 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -173,65 +173,59 @@ struct dentry_operations {
173173
*/
174174

175175
/* d_flags entries */
176-
#define DCACHE_OP_HASH BIT(0)
177-
#define DCACHE_OP_COMPARE BIT(1)
178-
#define DCACHE_OP_REVALIDATE BIT(2)
179-
#define DCACHE_OP_DELETE BIT(3)
180-
#define DCACHE_OP_PRUNE BIT(4)
181-
182-
#define DCACHE_DISCONNECTED BIT(5)
183-
/* This dentry is possibly not currently connected to the dcache tree, in
184-
* which case its parent will either be itself, or will have this flag as
185-
* well. nfsd will not use a dentry with this bit set, but will first
186-
* endeavour to clear the bit either by discovering that it is connected,
187-
* or by performing lookup operations. Any filesystem which supports
188-
* nfsd_operations MUST have a lookup function which, if it finds a
189-
* directory inode with a DCACHE_DISCONNECTED dentry, will d_move that
190-
* dentry into place and return that dentry rather than the passed one,
191-
* typically using d_splice_alias. */
192-
193-
#define DCACHE_REFERENCED BIT(6) /* Recently used, don't discard. */
194-
195-
#define DCACHE_DONTCACHE BIT(7) /* Purge from memory on final dput() */
196-
197-
#define DCACHE_CANT_MOUNT BIT(8)
198-
#define DCACHE_GENOCIDE BIT(9)
199-
#define DCACHE_SHRINK_LIST BIT(10)
200-
201-
#define DCACHE_OP_WEAK_REVALIDATE BIT(11)
202-
203-
#define DCACHE_NFSFS_RENAMED BIT(12)
204-
/* this dentry has been "silly renamed" and has to be deleted on the last
205-
* dput() */
206-
#define DCACHE_FSNOTIFY_PARENT_WATCHED BIT(13)
207-
/* Parent inode is watched by some fsnotify listener */
208-
209-
#define DCACHE_DENTRY_KILLED BIT(14)
210-
211-
#define DCACHE_MOUNTED BIT(15) /* is a mountpoint */
212-
#define DCACHE_NEED_AUTOMOUNT BIT(16) /* handle automount on this dir */
213-
#define DCACHE_MANAGE_TRANSIT BIT(17) /* manage transit from this dirent */
176+
enum dentry_flags {
177+
DCACHE_OP_HASH = BIT(0),
178+
DCACHE_OP_COMPARE = BIT(1),
179+
DCACHE_OP_REVALIDATE = BIT(2),
180+
DCACHE_OP_DELETE = BIT(3),
181+
DCACHE_OP_PRUNE = BIT(4),
182+
/*
183+
* This dentry is possibly not currently connected to the dcache tree,
184+
* in which case its parent will either be itself, or will have this
185+
* flag as well. nfsd will not use a dentry with this bit set, but will
186+
* first endeavour to clear the bit either by discovering that it is
187+
* connected, or by performing lookup operations. Any filesystem which
188+
* supports nfsd_operations MUST have a lookup function which, if it
189+
* finds a directory inode with a DCACHE_DISCONNECTED dentry, will
190+
* d_move that dentry into place and return that dentry rather than the
191+
* passed one, typically using d_splice_alias.
192+
*/
193+
DCACHE_DISCONNECTED = BIT(5),
194+
DCACHE_REFERENCED = BIT(6), /* Recently used, don't discard. */
195+
DCACHE_DONTCACHE = BIT(7), /* Purge from memory on final dput() */
196+
DCACHE_CANT_MOUNT = BIT(8),
197+
DCACHE_GENOCIDE = BIT(9),
198+
DCACHE_SHRINK_LIST = BIT(10),
199+
DCACHE_OP_WEAK_REVALIDATE = BIT(11),
200+
/*
201+
* this dentry has been "silly renamed" and has to be deleted on the
202+
* last dput()
203+
*/
204+
DCACHE_NFSFS_RENAMED = BIT(12),
205+
DCACHE_FSNOTIFY_PARENT_WATCHED = BIT(13), /* Parent inode is watched by some fsnotify listener */
206+
DCACHE_DENTRY_KILLED = BIT(14),
207+
DCACHE_MOUNTED = BIT(15), /* is a mountpoint */
208+
DCACHE_NEED_AUTOMOUNT = BIT(16), /* handle automount on this dir */
209+
DCACHE_MANAGE_TRANSIT = BIT(17), /* manage transit from this dirent */
210+
DCACHE_LRU_LIST = BIT(18),
211+
DCACHE_ENTRY_TYPE = (7 << 19), /* bits 19..21 are for storing type: */
212+
DCACHE_MISS_TYPE = (0 << 19), /* Negative dentry */
213+
DCACHE_WHITEOUT_TYPE = (1 << 19), /* Whiteout dentry (stop pathwalk) */
214+
DCACHE_DIRECTORY_TYPE = (2 << 19), /* Normal directory */
215+
DCACHE_AUTODIR_TYPE = (3 << 19), /* Lookupless directory (presumed automount) */
216+
DCACHE_REGULAR_TYPE = (4 << 19), /* Regular file type */
217+
DCACHE_SPECIAL_TYPE = (5 << 19), /* Other file type */
218+
DCACHE_SYMLINK_TYPE = (6 << 19), /* Symlink */
219+
DCACHE_NOKEY_NAME = BIT(22), /* Encrypted name encoded without key */
220+
DCACHE_OP_REAL = BIT(23),
221+
DCACHE_PAR_LOOKUP = BIT(24), /* being looked up (with parent locked shared) */
222+
DCACHE_DENTRY_CURSOR = BIT(25),
223+
DCACHE_NORCU = BIT(26), /* No RCU delay for freeing */
224+
};
225+
214226
#define DCACHE_MANAGED_DENTRY \
215227
(DCACHE_MOUNTED|DCACHE_NEED_AUTOMOUNT|DCACHE_MANAGE_TRANSIT)
216228

217-
#define DCACHE_LRU_LIST BIT(18)
218-
219-
#define DCACHE_ENTRY_TYPE (7 << 19) /* bits 19..21 are for storing type: */
220-
#define DCACHE_MISS_TYPE (0 << 19) /* Negative dentry */
221-
#define DCACHE_WHITEOUT_TYPE (1 << 19) /* Whiteout dentry (stop pathwalk) */
222-
#define DCACHE_DIRECTORY_TYPE (2 << 19) /* Normal directory */
223-
#define DCACHE_AUTODIR_TYPE (3 << 19) /* Lookupless directory (presumed automount) */
224-
#define DCACHE_REGULAR_TYPE (4 << 19) /* Regular file type */
225-
#define DCACHE_SPECIAL_TYPE (5 << 19) /* Other file type */
226-
#define DCACHE_SYMLINK_TYPE (6 << 19) /* Symlink */
227-
228-
#define DCACHE_NOKEY_NAME BIT(22) /* Encrypted name encoded without key */
229-
#define DCACHE_OP_REAL BIT(23)
230-
231-
#define DCACHE_PAR_LOOKUP BIT(24) /* being looked up (with parent locked shared) */
232-
#define DCACHE_DENTRY_CURSOR BIT(25)
233-
#define DCACHE_NORCU BIT(26) /* No RCU delay for freeing */
234-
235229
extern seqlock_t rename_lock;
236230

237231
/*

0 commit comments

Comments
 (0)