make sure that DNAME_INLINE_LEN is a multiple of word size
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 10 Dec 2024 00:15:58 +0000 (19:15 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 17 Jan 2025 22:46:05 +0000 (17:46 -0500)
... calling the number of words DNAME_INLINE_WORDS.

The next step will be to have a structure to hold inline name arrays
(both in dentry and in name_snapshot) and use that to alias the
existing arrays of unsigned char there.  That will allow both
full-structure copies and convenient word-by-word accesses.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/dcache.c
include/linux/dcache.h

index b4d5e9e1e43da012cf24c379800feb9cde806ea8..ea0f0bea511becdac275012ff47804891fc1a2c2 100644 (file)
@@ -2748,9 +2748,7 @@ static void swap_names(struct dentry *dentry, struct dentry *target)
                        /*
                         * Both are internal.
                         */
-                       unsigned int i;
-                       BUILD_BUG_ON(!IS_ALIGNED(DNAME_INLINE_LEN, sizeof(long)));
-                       for (i = 0; i < DNAME_INLINE_LEN / sizeof(long); i++) {
+                       for (int i = 0; i < DNAME_INLINE_WORDS; i++) {
                                swap(((long *) &dentry->d_iname)[i],
                                     ((long *) &target->d_iname)[i]);
                        }
index bff956f7b2b984b2c7ca17728ea2cbeb6347e7d5..42dd89beaf4ed6050344d90017328f16950a9aab 100644 (file)
@@ -68,15 +68,17 @@ extern const struct qstr dotdot_name;
  * large memory footprint increase).
  */
 #ifdef CONFIG_64BIT
-# define DNAME_INLINE_LEN 40 /* 192 bytes */
+# define DNAME_INLINE_WORDS 5 /* 192 bytes */
 #else
 # ifdef CONFIG_SMP
-#  define DNAME_INLINE_LEN 36 /* 128 bytes */
+#  define DNAME_INLINE_WORDS 9 /* 128 bytes */
 # else
-#  define DNAME_INLINE_LEN 44 /* 128 bytes */
+#  define DNAME_INLINE_WORDS 11 /* 128 bytes */
 # endif
 #endif
 
+#define DNAME_INLINE_LEN (DNAME_INLINE_WORDS*sizeof(unsigned long))
+
 #define d_lock d_lockref.lock
 
 struct dentry {