Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ceph: enable/disable dentry complete flags via mount option

Enable/disable use of the dentry dir 'complete' flag via a mount option.
This lets the admin control whether ceph uses the dcache to satisfy
negative lookups or readdir when it has the entire directory contents in
its cache.

This is purely a performance optimization; correctness is guaranteed
whether it is enabled or not.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sage Weil <sage@newdream.net>

Sage Weil a40dc6cc 46f72b34

+50 -8
+13 -5
Documentation/filesystems/ceph.txt
··· 119 119 must rely on TCP's error correction to detect data corruption 120 120 in the data payload. 121 121 122 - noasyncreaddir 123 - Disable client's use its local cache to satisfy readdir 124 - requests. (This does not change correctness; the client uses 125 - cached metadata only when a lease or capability ensures it is 126 - valid.) 122 + dcache 123 + Use the dcache contents to perform negative lookups and 124 + readdir when the client has the entire directory contents in 125 + its cache. (This does not change correctness; the client uses 126 + cached metadata only when a lease or capability ensures it is 127 + valid.) 127 128 129 + nodcache 130 + Do not use the dcache as above. This avoids a significant amount of 131 + complex code, sacrificing performance without affecting correctness, 132 + and is useful for tracking down bugs. 133 + 134 + noasyncreaddir 135 + Do not use the dcache as above for readdir. 128 136 129 137 More Information 130 138 ================
+22 -3
fs/ceph/dir.c
··· 1094 1094 */ 1095 1095 void ceph_dir_set_complete(struct inode *inode) 1096 1096 { 1097 - /* not yet implemented */ 1097 + struct dentry *dentry = d_find_any_alias(inode); 1098 + 1099 + if (dentry && ceph_dentry(dentry) && 1100 + ceph_test_mount_opt(ceph_sb_to_client(dentry->d_sb), DCACHE)) { 1101 + dout(" marking %p (%p) complete\n", inode, dentry); 1102 + set_bit(CEPH_D_COMPLETE, &ceph_dentry(dentry)->flags); 1103 + } 1104 + dput(dentry); 1098 1105 } 1099 1106 1100 1107 void ceph_dir_clear_complete(struct inode *inode) 1101 1108 { 1102 - /* not yet implemented */ 1109 + struct dentry *dentry = d_find_any_alias(inode); 1110 + 1111 + if (dentry && ceph_dentry(dentry)) { 1112 + dout(" marking %p (%p) complete\n", inode, dentry); 1113 + set_bit(CEPH_D_COMPLETE, &ceph_dentry(dentry)->flags); 1114 + } 1115 + dput(dentry); 1103 1116 } 1104 1117 1105 1118 bool ceph_dir_test_complete(struct inode *inode) 1106 1119 { 1107 - /* not yet implemented */ 1120 + struct dentry *dentry = d_find_any_alias(inode); 1121 + 1122 + if (dentry && ceph_dentry(dentry)) { 1123 + dout(" marking %p (%p) NOT complete\n", inode, dentry); 1124 + clear_bit(CEPH_D_COMPLETE, &ceph_dentry(dentry)->flags); 1125 + } 1126 + dput(dentry); 1108 1127 return false; 1109 1128 } 1110 1129
+14
fs/ceph/super.c
··· 131 131 Opt_rbytes, 132 132 Opt_norbytes, 133 133 Opt_noasyncreaddir, 134 + Opt_dcache, 135 + Opt_nodcache, 134 136 Opt_ino32, 135 137 }; 136 138 ··· 154 152 {Opt_rbytes, "rbytes"}, 155 153 {Opt_norbytes, "norbytes"}, 156 154 {Opt_noasyncreaddir, "noasyncreaddir"}, 155 + {Opt_dcache, "dcache"}, 156 + {Opt_nodcache, "nodcache"}, 157 157 {Opt_ino32, "ino32"}, 158 158 {-1, NULL} 159 159 }; ··· 234 230 break; 235 231 case Opt_noasyncreaddir: 236 232 fsopt->flags |= CEPH_MOUNT_OPT_NOASYNCREADDIR; 233 + break; 234 + case Opt_dcache: 235 + fsopt->flags |= CEPH_MOUNT_OPT_DCACHE; 236 + break; 237 + case Opt_nodcache: 238 + fsopt->flags &= ~CEPH_MOUNT_OPT_DCACHE; 237 239 break; 238 240 case Opt_ino32: 239 241 fsopt->flags |= CEPH_MOUNT_OPT_INO32; ··· 387 377 seq_puts(m, ",norbytes"); 388 378 if (fsopt->flags & CEPH_MOUNT_OPT_NOASYNCREADDIR) 389 379 seq_puts(m, ",noasyncreaddir"); 380 + if (fsopt->flags & CEPH_MOUNT_OPT_DCACHE) 381 + seq_puts(m, ",dcache"); 382 + else 383 + seq_puts(m, ",nodcache"); 390 384 391 385 if (fsopt->wsize) 392 386 seq_printf(m, ",wsize=%d", fsopt->wsize);
+1
fs/ceph/super.h
··· 28 28 #define CEPH_MOUNT_OPT_RBYTES (1<<5) /* dir st_bytes = rbytes */ 29 29 #define CEPH_MOUNT_OPT_NOASYNCREADDIR (1<<7) /* no dcache readdir */ 30 30 #define CEPH_MOUNT_OPT_INO32 (1<<8) /* 32 bit inos */ 31 + #define CEPH_MOUNT_OPT_DCACHE (1<<9) /* use dcache for readdir etc */ 31 32 32 33 #define CEPH_MOUNT_OPT_DEFAULT (CEPH_MOUNT_OPT_RBYTES) 33 34