Commit a40dc6cc2e121abcbd1b22583ef5447763df510c

Authored by Sage Weil
1 parent 46f72b3492

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>

Showing 4 changed files with 50 additions and 8 deletions Side-by-side Diff

Documentation/filesystems/ceph.txt
... ... @@ -119,12 +119,20 @@
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 ================
... ... @@ -1094,17 +1094,36 @@
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  
... ... @@ -131,6 +131,8 @@
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  
... ... @@ -152,6 +154,8 @@
152 154 {Opt_rbytes, "rbytes"},
153 155 {Opt_norbytes, "norbytes"},
154 156 {Opt_noasyncreaddir, "noasyncreaddir"},
  157 + {Opt_dcache, "dcache"},
  158 + {Opt_nodcache, "nodcache"},
155 159 {Opt_ino32, "ino32"},
156 160 {-1, NULL}
157 161 };
... ... @@ -231,6 +235,12 @@
231 235 case Opt_noasyncreaddir:
232 236 fsopt->flags |= CEPH_MOUNT_OPT_NOASYNCREADDIR;
233 237 break;
  238 + case Opt_dcache:
  239 + fsopt->flags |= CEPH_MOUNT_OPT_DCACHE;
  240 + break;
  241 + case Opt_nodcache:
  242 + fsopt->flags &= ~CEPH_MOUNT_OPT_DCACHE;
  243 + break;
234 244 case Opt_ino32:
235 245 fsopt->flags |= CEPH_MOUNT_OPT_INO32;
236 246 break;
... ... @@ -377,6 +387,10 @@
377 387 seq_puts(m, ",norbytes");
378 388 if (fsopt->flags & CEPH_MOUNT_OPT_NOASYNCREADDIR)
379 389 seq_puts(m, ",noasyncreaddir");
  390 + if (fsopt->flags & CEPH_MOUNT_OPT_DCACHE)
  391 + seq_puts(m, ",dcache");
  392 + else
  393 + seq_puts(m, ",nodcache");
380 394  
381 395 if (fsopt->wsize)
382 396 seq_printf(m, ",wsize=%d", fsopt->wsize);
... ... @@ -28,6 +28,7 @@
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