aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-05-30 14:17:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-30 14:17:19 -0400
commitaf56e0aa35f3ae2a4c1a6d1000702df1dd78cb76 (patch)
tree304bd85e5db2d07efa2913aa7c6313b918cfbfdb /fs
parent65a50c951a38e9827dd9655b6e686bde912e799b (diff)
parent6bd9adbdf9ca6a052b0b7455ac67b925eb38cfad (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client
Pull ceph updates from Sage Weil: "There are some updates and cleanups to the CRUSH placement code, a bug fix with incremental maps, several cleanups and fixes from Josh Durgin in the RBD block device code, a series of cleanups and bug fixes from Alex Elder in the messenger code, and some miscellaneous bounds checking and gfp cleanups/fixes." Fix up trivial conflicts in net/ceph/{messenger.c,osdmap.c} due to the networking people preferring "unsigned int" over just "unsigned". * git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client: (45 commits) libceph: fix pg_temp updates libceph: avoid unregistering osd request when not registered ceph: add auth buf in prepare_write_connect() ceph: rename prepare_connect_authorizer() ceph: return pointer from prepare_connect_authorizer() ceph: use info returned by get_authorizer ceph: have get_authorizer methods return pointers ceph: ensure auth ops are defined before use ceph: messenger: reduce args to create_authorizer ceph: define ceph_auth_handshake type ceph: messenger: check return from get_authorizer ceph: messenger: rework prepare_connect_authorizer() ceph: messenger: check prepare_write_connect() result ceph: don't set WRITE_PENDING too early ceph: drop msgr argument from prepare_write_connect() ceph: messenger: send banner in process_connect() ceph: messenger: reset connection kvec caller libceph: don't reset kvec in prepare_write_banner() ceph: ignore preferred_osd field ceph: fully initialize new layout ...
Diffstat (limited to 'fs')
-rw-r--r--fs/ceph/file.c1
-rw-r--r--fs/ceph/ioctl.c102
-rw-r--r--fs/ceph/ioctl.h2
-rw-r--r--fs/ceph/mds_client.c54
-rw-r--r--fs/ceph/mds_client.h5
-rw-r--r--fs/ceph/xattr.c9
6 files changed, 75 insertions, 98 deletions
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index ed72428d9c75..988d4f302e48 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -54,7 +54,6 @@ prepare_open_request(struct super_block *sb, int flags, int create_mode)
54 req->r_fmode = ceph_flags_to_mode(flags); 54 req->r_fmode = ceph_flags_to_mode(flags);
55 req->r_args.open.flags = cpu_to_le32(flags); 55 req->r_args.open.flags = cpu_to_le32(flags);
56 req->r_args.open.mode = cpu_to_le32(create_mode); 56 req->r_args.open.mode = cpu_to_le32(create_mode);
57 req->r_args.open.preferred = cpu_to_le32(-1);
58out: 57out:
59 return req; 58 return req;
60} 59}
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index 790914a598dd..8e3fb69fbe62 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -26,8 +26,7 @@ static long ceph_ioctl_get_layout(struct file *file, void __user *arg)
26 l.stripe_count = ceph_file_layout_stripe_count(ci->i_layout); 26 l.stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
27 l.object_size = ceph_file_layout_object_size(ci->i_layout); 27 l.object_size = ceph_file_layout_object_size(ci->i_layout);
28 l.data_pool = le32_to_cpu(ci->i_layout.fl_pg_pool); 28 l.data_pool = le32_to_cpu(ci->i_layout.fl_pg_pool);
29 l.preferred_osd = 29 l.preferred_osd = (s32)-1;
30 (s32)le32_to_cpu(ci->i_layout.fl_pg_preferred);
31 if (copy_to_user(arg, &l, sizeof(l))) 30 if (copy_to_user(arg, &l, sizeof(l)))
32 return -EFAULT; 31 return -EFAULT;
33 } 32 }
@@ -35,6 +34,32 @@ static long ceph_ioctl_get_layout(struct file *file, void __user *arg)
35 return err; 34 return err;
36} 35}
37 36
37static long __validate_layout(struct ceph_mds_client *mdsc,
38 struct ceph_ioctl_layout *l)
39{
40 int i, err;
41
42 /* validate striping parameters */
43 if ((l->object_size & ~PAGE_MASK) ||
44 (l->stripe_unit & ~PAGE_MASK) ||
45 ((unsigned)l->object_size % (unsigned)l->stripe_unit))
46 return -EINVAL;
47
48 /* make sure it's a valid data pool */
49 mutex_lock(&mdsc->mutex);
50 err = -EINVAL;
51 for (i = 0; i < mdsc->mdsmap->m_num_data_pg_pools; i++)
52 if (mdsc->mdsmap->m_data_pg_pools[i] == l->data_pool) {
53 err = 0;
54 break;
55 }
56 mutex_unlock(&mdsc->mutex);
57 if (err)
58 return err;
59
60 return 0;
61}
62
38static long ceph_ioctl_set_layout(struct file *file, void __user *arg) 63static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
39{ 64{
40 struct inode *inode = file->f_dentry->d_inode; 65 struct inode *inode = file->f_dentry->d_inode;
@@ -44,52 +69,40 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
44 struct ceph_ioctl_layout l; 69 struct ceph_ioctl_layout l;
45 struct ceph_inode_info *ci = ceph_inode(file->f_dentry->d_inode); 70 struct ceph_inode_info *ci = ceph_inode(file->f_dentry->d_inode);
46 struct ceph_ioctl_layout nl; 71 struct ceph_ioctl_layout nl;
47 int err, i; 72 int err;
48 73
49 if (copy_from_user(&l, arg, sizeof(l))) 74 if (copy_from_user(&l, arg, sizeof(l)))
50 return -EFAULT; 75 return -EFAULT;
51 76
52 /* validate changed params against current layout */ 77 /* validate changed params against current layout */
53 err = ceph_do_getattr(file->f_dentry->d_inode, CEPH_STAT_CAP_LAYOUT); 78 err = ceph_do_getattr(file->f_dentry->d_inode, CEPH_STAT_CAP_LAYOUT);
54 if (!err) { 79 if (err)
55 nl.stripe_unit = ceph_file_layout_su(ci->i_layout);
56 nl.stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
57 nl.object_size = ceph_file_layout_object_size(ci->i_layout);
58 nl.data_pool = le32_to_cpu(ci->i_layout.fl_pg_pool);
59 nl.preferred_osd =
60 (s32)le32_to_cpu(ci->i_layout.fl_pg_preferred);
61 } else
62 return err; 80 return err;
63 81
82 memset(&nl, 0, sizeof(nl));
64 if (l.stripe_count) 83 if (l.stripe_count)
65 nl.stripe_count = l.stripe_count; 84 nl.stripe_count = l.stripe_count;
85 else
86 nl.stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
66 if (l.stripe_unit) 87 if (l.stripe_unit)
67 nl.stripe_unit = l.stripe_unit; 88 nl.stripe_unit = l.stripe_unit;
89 else
90 nl.stripe_unit = ceph_file_layout_su(ci->i_layout);
68 if (l.object_size) 91 if (l.object_size)
69 nl.object_size = l.object_size; 92 nl.object_size = l.object_size;
93 else
94 nl.object_size = ceph_file_layout_object_size(ci->i_layout);
70 if (l.data_pool) 95 if (l.data_pool)
71 nl.data_pool = l.data_pool; 96 nl.data_pool = l.data_pool;
72 if (l.preferred_osd) 97 else
73 nl.preferred_osd = l.preferred_osd; 98 nl.data_pool = ceph_file_layout_pg_pool(ci->i_layout);
74 99
75 if ((nl.object_size & ~PAGE_MASK) || 100 /* this is obsolete, and always -1 */
76 (nl.stripe_unit & ~PAGE_MASK) || 101 nl.preferred_osd = le64_to_cpu(-1);
77 ((unsigned)nl.object_size % (unsigned)nl.stripe_unit))
78 return -EINVAL;
79 102
80 /* make sure it's a valid data pool */ 103 err = __validate_layout(mdsc, &nl);
81 if (l.data_pool > 0) { 104 if (err)
82 mutex_lock(&mdsc->mutex); 105 return err;
83 err = -EINVAL;
84 for (i = 0; i < mdsc->mdsmap->m_num_data_pg_pools; i++)
85 if (mdsc->mdsmap->m_data_pg_pools[i] == l.data_pool) {
86 err = 0;
87 break;
88 }
89 mutex_unlock(&mdsc->mutex);
90 if (err)
91 return err;
92 }
93 106
94 req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SETLAYOUT, 107 req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SETLAYOUT,
95 USE_AUTH_MDS); 108 USE_AUTH_MDS);
@@ -106,8 +119,6 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
106 req->r_args.setlayout.layout.fl_object_size = 119 req->r_args.setlayout.layout.fl_object_size =
107 cpu_to_le32(l.object_size); 120 cpu_to_le32(l.object_size);
108 req->r_args.setlayout.layout.fl_pg_pool = cpu_to_le32(l.data_pool); 121 req->r_args.setlayout.layout.fl_pg_pool = cpu_to_le32(l.data_pool);
109 req->r_args.setlayout.layout.fl_pg_preferred =
110 cpu_to_le32(l.preferred_osd);
111 122
112 parent_inode = ceph_get_dentry_parent_inode(file->f_dentry); 123 parent_inode = ceph_get_dentry_parent_inode(file->f_dentry);
113 err = ceph_mdsc_do_request(mdsc, parent_inode, req); 124 err = ceph_mdsc_do_request(mdsc, parent_inode, req);
@@ -127,33 +138,16 @@ static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg)
127 struct inode *inode = file->f_dentry->d_inode; 138 struct inode *inode = file->f_dentry->d_inode;
128 struct ceph_mds_request *req; 139 struct ceph_mds_request *req;
129 struct ceph_ioctl_layout l; 140 struct ceph_ioctl_layout l;
130 int err, i; 141 int err;
131 struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc; 142 struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
132 143
133 /* copy and validate */ 144 /* copy and validate */
134 if (copy_from_user(&l, arg, sizeof(l))) 145 if (copy_from_user(&l, arg, sizeof(l)))
135 return -EFAULT; 146 return -EFAULT;
136 147
137 if ((l.object_size & ~PAGE_MASK) || 148 err = __validate_layout(mdsc, &l);
138 (l.stripe_unit & ~PAGE_MASK) || 149 if (err)
139 !l.stripe_unit || 150 return err;
140 (l.object_size &&
141 (unsigned)l.object_size % (unsigned)l.stripe_unit))
142 return -EINVAL;
143
144 /* make sure it's a valid data pool */
145 if (l.data_pool > 0) {
146 mutex_lock(&mdsc->mutex);
147 err = -EINVAL;
148 for (i = 0; i < mdsc->mdsmap->m_num_data_pg_pools; i++)
149 if (mdsc->mdsmap->m_data_pg_pools[i] == l.data_pool) {
150 err = 0;
151 break;
152 }
153 mutex_unlock(&mdsc->mutex);
154 if (err)
155 return err;
156 }
157 151
158 req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SETDIRLAYOUT, 152 req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SETDIRLAYOUT,
159 USE_AUTH_MDS); 153 USE_AUTH_MDS);
@@ -171,8 +165,6 @@ static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg)
171 cpu_to_le32(l.object_size); 165 cpu_to_le32(l.object_size);
172 req->r_args.setlayout.layout.fl_pg_pool = 166 req->r_args.setlayout.layout.fl_pg_pool =
173 cpu_to_le32(l.data_pool); 167 cpu_to_le32(l.data_pool);
174 req->r_args.setlayout.layout.fl_pg_preferred =
175 cpu_to_le32(l.preferred_osd);
176 168
177 err = ceph_mdsc_do_request(mdsc, inode, req); 169 err = ceph_mdsc_do_request(mdsc, inode, req);
178 ceph_mdsc_put_request(req); 170 ceph_mdsc_put_request(req);
diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h
index be4a60487333..c77028afb1e1 100644
--- a/fs/ceph/ioctl.h
+++ b/fs/ceph/ioctl.h
@@ -34,6 +34,8 @@
34struct ceph_ioctl_layout { 34struct ceph_ioctl_layout {
35 __u64 stripe_unit, stripe_count, object_size; 35 __u64 stripe_unit, stripe_count, object_size;
36 __u64 data_pool; 36 __u64 data_pool;
37
38 /* obsolete. new values ignored, always return -1 */
37 __s64 preferred_osd; 39 __s64 preferred_osd;
38}; 40};
39 41
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 89971e137aab..200bc87eceb1 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -334,10 +334,10 @@ void ceph_put_mds_session(struct ceph_mds_session *s)
334 dout("mdsc put_session %p %d -> %d\n", s, 334 dout("mdsc put_session %p %d -> %d\n", s,
335 atomic_read(&s->s_ref), atomic_read(&s->s_ref)-1); 335 atomic_read(&s->s_ref), atomic_read(&s->s_ref)-1);
336 if (atomic_dec_and_test(&s->s_ref)) { 336 if (atomic_dec_and_test(&s->s_ref)) {
337 if (s->s_authorizer) 337 if (s->s_auth.authorizer)
338 s->s_mdsc->fsc->client->monc.auth->ops->destroy_authorizer( 338 s->s_mdsc->fsc->client->monc.auth->ops->destroy_authorizer(
339 s->s_mdsc->fsc->client->monc.auth, 339 s->s_mdsc->fsc->client->monc.auth,
340 s->s_authorizer); 340 s->s_auth.authorizer);
341 kfree(s); 341 kfree(s);
342 } 342 }
343} 343}
@@ -3395,39 +3395,33 @@ out:
3395/* 3395/*
3396 * authentication 3396 * authentication
3397 */ 3397 */
3398static int get_authorizer(struct ceph_connection *con, 3398
3399 void **buf, int *len, int *proto, 3399/*
3400 void **reply_buf, int *reply_len, int force_new) 3400 * Note: returned pointer is the address of a structure that's
3401 * managed separately. Caller must *not* attempt to free it.
3402 */
3403static struct ceph_auth_handshake *get_authorizer(struct ceph_connection *con,
3404 int *proto, int force_new)
3401{ 3405{
3402 struct ceph_mds_session *s = con->private; 3406 struct ceph_mds_session *s = con->private;
3403 struct ceph_mds_client *mdsc = s->s_mdsc; 3407 struct ceph_mds_client *mdsc = s->s_mdsc;
3404 struct ceph_auth_client *ac = mdsc->fsc->client->monc.auth; 3408 struct ceph_auth_client *ac = mdsc->fsc->client->monc.auth;
3405 int ret = 0; 3409 struct ceph_auth_handshake *auth = &s->s_auth;
3406
3407 if (force_new && s->s_authorizer) {
3408 ac->ops->destroy_authorizer(ac, s->s_authorizer);
3409 s->s_authorizer = NULL;
3410 }
3411 if (s->s_authorizer == NULL) {
3412 if (ac->ops->create_authorizer) {
3413 ret = ac->ops->create_authorizer(
3414 ac, CEPH_ENTITY_TYPE_MDS,
3415 &s->s_authorizer,
3416 &s->s_authorizer_buf,
3417 &s->s_authorizer_buf_len,
3418 &s->s_authorizer_reply_buf,
3419 &s->s_authorizer_reply_buf_len);
3420 if (ret)
3421 return ret;
3422 }
3423 }
3424 3410
3411 if (force_new && auth->authorizer) {
3412 if (ac->ops && ac->ops->destroy_authorizer)
3413 ac->ops->destroy_authorizer(ac, auth->authorizer);
3414 auth->authorizer = NULL;
3415 }
3416 if (!auth->authorizer && ac->ops && ac->ops->create_authorizer) {
3417 int ret = ac->ops->create_authorizer(ac, CEPH_ENTITY_TYPE_MDS,
3418 auth);
3419 if (ret)
3420 return ERR_PTR(ret);
3421 }
3425 *proto = ac->protocol; 3422 *proto = ac->protocol;
3426 *buf = s->s_authorizer_buf; 3423
3427 *len = s->s_authorizer_buf_len; 3424 return auth;
3428 *reply_buf = s->s_authorizer_reply_buf;
3429 *reply_len = s->s_authorizer_reply_buf_len;
3430 return 0;
3431} 3425}
3432 3426
3433 3427
@@ -3437,7 +3431,7 @@ static int verify_authorizer_reply(struct ceph_connection *con, int len)
3437 struct ceph_mds_client *mdsc = s->s_mdsc; 3431 struct ceph_mds_client *mdsc = s->s_mdsc;
3438 struct ceph_auth_client *ac = mdsc->fsc->client->monc.auth; 3432 struct ceph_auth_client *ac = mdsc->fsc->client->monc.auth;
3439 3433
3440 return ac->ops->verify_authorizer_reply(ac, s->s_authorizer, len); 3434 return ac->ops->verify_authorizer_reply(ac, s->s_auth.authorizer, len);
3441} 3435}
3442 3436
3443static int invalidate_authorizer(struct ceph_connection *con) 3437static int invalidate_authorizer(struct ceph_connection *con)
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
index 8c7c04ebb595..dd26846dd71d 100644
--- a/fs/ceph/mds_client.h
+++ b/fs/ceph/mds_client.h
@@ -11,6 +11,7 @@
11#include <linux/ceph/types.h> 11#include <linux/ceph/types.h>
12#include <linux/ceph/messenger.h> 12#include <linux/ceph/messenger.h>
13#include <linux/ceph/mdsmap.h> 13#include <linux/ceph/mdsmap.h>
14#include <linux/ceph/auth.h>
14 15
15/* 16/*
16 * Some lock dependencies: 17 * Some lock dependencies:
@@ -113,9 +114,7 @@ struct ceph_mds_session {
113 114
114 struct ceph_connection s_con; 115 struct ceph_connection s_con;
115 116
116 struct ceph_authorizer *s_authorizer; 117 struct ceph_auth_handshake s_auth;
117 void *s_authorizer_buf, *s_authorizer_reply_buf;
118 size_t s_authorizer_buf_len, s_authorizer_reply_buf_len;
119 118
120 /* protected by s_gen_ttl_lock */ 119 /* protected by s_gen_ttl_lock */
121 spinlock_t s_gen_ttl_lock; 120 spinlock_t s_gen_ttl_lock;
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 35b86331d8a5..785cb3057c95 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -118,15 +118,6 @@ static size_t ceph_vxattrcb_file_layout(struct ceph_inode_info *ci, char *val,
118 (unsigned long long)ceph_file_layout_su(ci->i_layout), 118 (unsigned long long)ceph_file_layout_su(ci->i_layout),
119 (unsigned long long)ceph_file_layout_stripe_count(ci->i_layout), 119 (unsigned long long)ceph_file_layout_stripe_count(ci->i_layout),
120 (unsigned long long)ceph_file_layout_object_size(ci->i_layout)); 120 (unsigned long long)ceph_file_layout_object_size(ci->i_layout));
121
122 if (ceph_file_layout_pg_preferred(ci->i_layout) >= 0) {
123 val += ret;
124 size -= ret;
125 ret += snprintf(val, size, "preferred_osd=%lld\n",
126 (unsigned long long)ceph_file_layout_pg_preferred(
127 ci->i_layout));
128 }
129
130 return ret; 121 return ret;
131} 122}
132 123