aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ceph/dir.c20
-rw-r--r--fs/ceph/export.c2
-rw-r--r--fs/ceph/inode.c2
-rw-r--r--fs/ceph/super.h2
-rw-r--r--include/linux/ceph/ceph_fs.h16
-rw-r--r--net/ceph/ceph_hash.c3
6 files changed, 41 insertions, 4 deletions
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index d902948a90d8..562f9884a4d9 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1216,6 +1216,26 @@ void ceph_dentry_lru_del(struct dentry *dn)
1216 } 1216 }
1217} 1217}
1218 1218
1219/*
1220 * Return name hash for a given dentry. This is dependent on
1221 * the parent directory's hash function.
1222 */
1223unsigned ceph_dentry_hash(struct dentry *dn)
1224{
1225 struct inode *dir = dn->d_parent->d_inode;
1226 struct ceph_inode_info *dci = ceph_inode(dir);
1227
1228 switch (dci->i_dir_layout.dl_dir_hash) {
1229 case 0: /* for backward compat */
1230 case CEPH_STR_HASH_LINUX:
1231 return dn->d_name.hash;
1232
1233 default:
1234 return ceph_str_hash(dci->i_dir_layout.dl_dir_hash,
1235 dn->d_name.name, dn->d_name.len);
1236 }
1237}
1238
1219const struct file_operations ceph_dir_fops = { 1239const struct file_operations ceph_dir_fops = {
1220 .read = ceph_read_dir, 1240 .read = ceph_read_dir,
1221 .readdir = ceph_readdir, 1241 .readdir = ceph_readdir,
diff --git a/fs/ceph/export.c b/fs/ceph/export.c
index 2297d9426992..e41056174bf8 100644
--- a/fs/ceph/export.c
+++ b/fs/ceph/export.c
@@ -59,7 +59,7 @@ static int ceph_encode_fh(struct dentry *dentry, u32 *rawfh, int *max_len,
59 dout("encode_fh %p connectable\n", dentry); 59 dout("encode_fh %p connectable\n", dentry);
60 cfh->ino = ceph_ino(dentry->d_inode); 60 cfh->ino = ceph_ino(dentry->d_inode);
61 cfh->parent_ino = ceph_ino(parent->d_inode); 61 cfh->parent_ino = ceph_ino(parent->d_inode);
62 cfh->parent_name_hash = parent->d_name.hash; 62 cfh->parent_name_hash = ceph_dentry_hash(parent);
63 *max_len = connected_handle_length; 63 *max_len = connected_handle_length;
64 type = 2; 64 type = 2;
65 } else if (*max_len >= handle_length) { 65 } else if (*max_len >= handle_length) {
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index bf1286588f26..045283ce4413 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -297,6 +297,8 @@ struct inode *ceph_alloc_inode(struct super_block *sb)
297 ci->i_release_count = 0; 297 ci->i_release_count = 0;
298 ci->i_symlink = NULL; 298 ci->i_symlink = NULL;
299 299
300 memset(&ci->i_dir_layout, 0, sizeof(ci->i_dir_layout));
301
300 ci->i_fragtree = RB_ROOT; 302 ci->i_fragtree = RB_ROOT;
301 mutex_init(&ci->i_fragtree_mutex); 303 mutex_init(&ci->i_fragtree_mutex);
302 304
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 7f01728a4657..6e0826695112 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -239,6 +239,7 @@ struct ceph_inode_info {
239 unsigned i_ceph_flags; 239 unsigned i_ceph_flags;
240 unsigned long i_release_count; 240 unsigned long i_release_count;
241 241
242 struct ceph_dir_layout i_dir_layout;
242 struct ceph_file_layout i_layout; 243 struct ceph_file_layout i_layout;
243 char *i_symlink; 244 char *i_symlink;
244 245
@@ -768,6 +769,7 @@ extern void ceph_dentry_lru_add(struct dentry *dn);
768extern void ceph_dentry_lru_touch(struct dentry *dn); 769extern void ceph_dentry_lru_touch(struct dentry *dn);
769extern void ceph_dentry_lru_del(struct dentry *dn); 770extern void ceph_dentry_lru_del(struct dentry *dn);
770extern void ceph_invalidate_dentry_lease(struct dentry *dentry); 771extern void ceph_invalidate_dentry_lease(struct dentry *dentry);
772extern unsigned ceph_dentry_hash(struct dentry *dn);
771 773
772/* 774/*
773 * our d_ops vary depending on whether the inode is live, 775 * our d_ops vary depending on whether the inode is live,
diff --git a/include/linux/ceph/ceph_fs.h b/include/linux/ceph/ceph_fs.h
index c3c74aef289d..09dcc0c2ffd5 100644
--- a/include/linux/ceph/ceph_fs.h
+++ b/include/linux/ceph/ceph_fs.h
@@ -43,6 +43,10 @@
43#define CEPH_FEATURE_NOSRCADDR (1<<1) 43#define CEPH_FEATURE_NOSRCADDR (1<<1)
44#define CEPH_FEATURE_MONCLOCKCHECK (1<<2) 44#define CEPH_FEATURE_MONCLOCKCHECK (1<<2)
45#define CEPH_FEATURE_FLOCK (1<<3) 45#define CEPH_FEATURE_FLOCK (1<<3)
46#define CEPH_FEATURE_SUBSCRIBE2 (1<<4)
47#define CEPH_FEATURE_MONNAMES (1<<5)
48#define CEPH_FEATURE_RECONNECT_SEQ (1<<6)
49#define CEPH_FEATURE_DIRLAYOUTHASH (1<<7)
46 50
47 51
48/* 52/*
@@ -55,10 +59,10 @@ struct ceph_file_layout {
55 __le32 fl_stripe_count; /* over this many objects */ 59 __le32 fl_stripe_count; /* over this many objects */
56 __le32 fl_object_size; /* until objects are this big, then move to 60 __le32 fl_object_size; /* until objects are this big, then move to
57 new objects */ 61 new objects */
58 __le32 fl_cas_hash; /* 0 = none; 1 = sha256 */ 62 __le32 fl_cas_hash; /* UNUSED. 0 = none; 1 = sha256 */
59 63
60 /* pg -> disk layout */ 64 /* pg -> disk layout */
61 __le32 fl_object_stripe_unit; /* for per-object parity, if any */ 65 __le32 fl_object_stripe_unit; /* UNUSED. for per-object parity, if any */
62 66
63 /* object -> pg layout */ 67 /* object -> pg layout */
64 __le32 fl_pg_preferred; /* preferred primary for pg (-1 for none) */ 68 __le32 fl_pg_preferred; /* preferred primary for pg (-1 for none) */
@@ -69,6 +73,12 @@ struct ceph_file_layout {
69 73
70int ceph_file_layout_is_valid(const struct ceph_file_layout *layout); 74int ceph_file_layout_is_valid(const struct ceph_file_layout *layout);
71 75
76struct ceph_dir_layout {
77 __u8 dl_dir_hash; /* see ceph_hash.h for ids */
78 __u8 dl_unused1;
79 __u16 dl_unused2;
80 __u32 dl_unused3;
81} __attribute__ ((packed));
72 82
73/* crypto algorithms */ 83/* crypto algorithms */
74#define CEPH_CRYPTO_NONE 0x0 84#define CEPH_CRYPTO_NONE 0x0
@@ -457,7 +467,7 @@ struct ceph_mds_reply_inode {
457 struct ceph_timespec rctime; 467 struct ceph_timespec rctime;
458 struct ceph_frag_tree_head fragtree; /* (must be at end of struct) */ 468 struct ceph_frag_tree_head fragtree; /* (must be at end of struct) */
459} __attribute__ ((packed)); 469} __attribute__ ((packed));
460/* followed by frag array, then symlink string, then xattr blob */ 470/* followed by frag array, symlink string, dir layout, xattr blob */
461 471
462/* reply_lease follows dname, and reply_inode */ 472/* reply_lease follows dname, and reply_inode */
463struct ceph_mds_reply_lease { 473struct ceph_mds_reply_lease {
diff --git a/net/ceph/ceph_hash.c b/net/ceph/ceph_hash.c
index 815ef8826796..0a1b53bce76d 100644
--- a/net/ceph/ceph_hash.c
+++ b/net/ceph/ceph_hash.c
@@ -1,5 +1,6 @@
1 1
2#include <linux/ceph/types.h> 2#include <linux/ceph/types.h>
3#include <linux/module.h>
3 4
4/* 5/*
5 * Robert Jenkin's hash function. 6 * Robert Jenkin's hash function.
@@ -104,6 +105,7 @@ unsigned ceph_str_hash(int type, const char *s, unsigned len)
104 return -1; 105 return -1;
105 } 106 }
106} 107}
108EXPORT_SYMBOL(ceph_str_hash);
107 109
108const char *ceph_str_hash_name(int type) 110const char *ceph_str_hash_name(int type)
109{ 111{
@@ -116,3 +118,4 @@ const char *ceph_str_hash_name(int type)
116 return "unknown"; 118 return "unknown";
117 } 119 }
118} 120}
121EXPORT_SYMBOL(ceph_str_hash_name);