Skip to content

Commit 969e5aa

Browse files
author
Alex Elder
committed
Merge branch 'testing' of github.com:ceph/ceph-client into v3.8-rc5-testing
2 parents 949db15 + 1ec3911 commit 969e5aa

14 files changed

Lines changed: 652 additions & 611 deletions

File tree

‎drivers/block/rbd.c‎

Lines changed: 444 additions & 411 deletions
Large diffs are not rendered by default.

‎fs/ceph/caps.c‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,16 @@ int ceph_add_cap(struct inode *inode,
611611

612612
if (flags & CEPH_CAP_FLAG_AUTH)
613613
ci->i_auth_cap = cap;
614-
else if (ci->i_auth_cap == cap)
614+
else if (ci->i_auth_cap == cap) {
615615
ci->i_auth_cap = NULL;
616+
spin_lock(&mdsc->cap_dirty_lock);
617+
if (!list_empty(&ci->i_dirty_item)) {
618+
dout(" moving %p to cap_dirty_migrating\n", inode);
619+
list_move(&ci->i_dirty_item,
620+
&mdsc->cap_dirty_migrating);
621+
}
622+
spin_unlock(&mdsc->cap_dirty_lock);
623+
}
616624

617625
dout("add_cap inode %p (%llx.%llx) cap %p %s now %s seq %d mds%d\n",
618626
inode, ceph_vinop(inode), cap, ceph_cap_string(issued),
@@ -1460,7 +1468,7 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
14601468
struct ceph_mds_client *mdsc = fsc->mdsc;
14611469
struct inode *inode = &ci->vfs_inode;
14621470
struct ceph_cap *cap;
1463-
int file_wanted, used;
1471+
int file_wanted, used, cap_used;
14641472
int took_snap_rwsem = 0; /* true if mdsc->snap_rwsem held */
14651473
int issued, implemented, want, retain, revoking, flushing = 0;
14661474
int mds = -1; /* keep track of how far we've gone through i_caps list
@@ -1563,9 +1571,14 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
15631571

15641572
/* NOTE: no side-effects allowed, until we take s_mutex */
15651573

1574+
cap_used = used;
1575+
if (ci->i_auth_cap && cap != ci->i_auth_cap)
1576+
cap_used &= ~ci->i_auth_cap->issued;
1577+
15661578
revoking = cap->implemented & ~cap->issued;
1567-
dout(" mds%d cap %p issued %s implemented %s revoking %s\n",
1579+
dout(" mds%d cap %p used %s issued %s implemented %s revoking %s\n",
15681580
cap->mds, cap, ceph_cap_string(cap->issued),
1581+
ceph_cap_string(cap_used),
15691582
ceph_cap_string(cap->implemented),
15701583
ceph_cap_string(revoking));
15711584

@@ -1593,7 +1606,7 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
15931606
}
15941607

15951608
/* completed revocation? going down and there are no caps? */
1596-
if (revoking && (revoking & used) == 0) {
1609+
if (revoking && (revoking & cap_used) == 0) {
15971610
dout("completed revocation of %s\n",
15981611
ceph_cap_string(cap->implemented & ~cap->issued));
15991612
goto ack;
@@ -1670,8 +1683,8 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
16701683
sent++;
16711684

16721685
/* __send_cap drops i_ceph_lock */
1673-
delayed += __send_cap(mdsc, cap, CEPH_CAP_OP_UPDATE, used, want,
1674-
retain, flushing, NULL);
1686+
delayed += __send_cap(mdsc, cap, CEPH_CAP_OP_UPDATE, cap_used,
1687+
want, retain, flushing, NULL);
16751688
goto retry; /* retake i_ceph_lock and restart our cap scan. */
16761689
}
16771690

@@ -2416,7 +2429,9 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
24162429
dout("mds wanted %s -> %s\n",
24172430
ceph_cap_string(le32_to_cpu(grant->wanted)),
24182431
ceph_cap_string(wanted));
2419-
grant->wanted = cpu_to_le32(wanted);
2432+
/* imported cap may not have correct mds_wanted */
2433+
if (le32_to_cpu(grant->op) == CEPH_CAP_OP_IMPORT)
2434+
check_caps = 1;
24202435
}
24212436

24222437
cap->seq = seq;
@@ -2820,6 +2835,9 @@ void ceph_handle_caps(struct ceph_mds_session *session,
28202835
dout(" mds%d seq %lld cap seq %u\n", session->s_mds, session->s_seq,
28212836
(unsigned)seq);
28222837

2838+
if (op == CEPH_CAP_OP_IMPORT)
2839+
ceph_add_cap_releases(mdsc, session);
2840+
28232841
/* lookup ino */
28242842
inode = ceph_find_inode(sb, vino);
28252843
ci = ceph_inode(inode);

‎fs/ceph/file.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
243243
err = ceph_mdsc_do_request(mdsc,
244244
(flags & (O_CREAT|O_TRUNC)) ? dir : NULL,
245245
req);
246+
if (err)
247+
goto out_err;
248+
246249
err = ceph_handle_snapdir(req, dentry, err);
247250
if (err == 0 && (flags & O_CREAT) && !req->r_reply_info.head->is_dentry)
248251
err = ceph_handle_notrace_create(dir, dentry);
@@ -263,6 +266,9 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
263266
err = finish_no_open(file, dn);
264267
} else {
265268
dout("atomic_open finish_open on dn %p\n", dn);
269+
if (req->r_op == CEPH_MDS_OP_CREATE && req->r_reply_info.has_create_ino) {
270+
*opened |= FILE_CREATED;
271+
}
266272
err = finish_open(file, dentry, ceph_open, opened);
267273
}
268274

‎fs/ceph/ioctl.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
194194
return -EFAULT;
195195

196196
down_read(&osdc->map_sem);
197-
r = ceph_calc_file_object_mapping(&ci->i_layout, dl.file_offset, &len,
197+
r = ceph_calc_file_object_mapping(&ci->i_layout, dl.file_offset, len,
198198
&dl.object_no, &dl.object_offset,
199199
&olen);
200200
if (r < 0)

‎fs/ceph/mds_client.c‎

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,30 @@ static int parse_reply_info_filelock(void **p, void *end,
232232
return -EIO;
233233
}
234234

235+
/*
236+
* parse create results
237+
*/
238+
static int parse_reply_info_create(void **p, void *end,
239+
struct ceph_mds_reply_info_parsed *info,
240+
int features)
241+
{
242+
if (features & CEPH_FEATURE_REPLY_CREATE_INODE) {
243+
if (*p == end) {
244+
info->has_create_ino = false;
245+
} else {
246+
info->has_create_ino = true;
247+
info->ino = ceph_decode_64(p);
248+
}
249+
}
250+
251+
if (unlikely(*p != end))
252+
goto bad;
253+
return 0;
254+
255+
bad:
256+
return -EIO;
257+
}
258+
235259
/*
236260
* parse extra results
237261
*/
@@ -241,8 +265,12 @@ static int parse_reply_info_extra(void **p, void *end,
241265
{
242266
if (info->head->op == CEPH_MDS_OP_GETFILELOCK)
243267
return parse_reply_info_filelock(p, end, info, features);
244-
else
268+
else if (info->head->op == CEPH_MDS_OP_READDIR)
245269
return parse_reply_info_dir(p, end, info, features);
270+
else if (info->head->op == CEPH_MDS_OP_CREATE)
271+
return parse_reply_info_create(p, end, info, features);
272+
else
273+
return -EIO;
246274
}
247275

248276
/*
@@ -2170,7 +2198,8 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg)
21702198
mutex_lock(&req->r_fill_mutex);
21712199
err = ceph_fill_trace(mdsc->fsc->sb, req, req->r_session);
21722200
if (err == 0) {
2173-
if (result == 0 && req->r_op != CEPH_MDS_OP_GETFILELOCK &&
2201+
if (result == 0 && (req->r_op == CEPH_MDS_OP_READDIR ||
2202+
req->r_op == CEPH_MDS_OP_LSSNAP) &&
21742203
rinfo->dir_nr)
21752204
ceph_readdir_prepopulate(req, req->r_session);
21762205
ceph_unreserve_caps(mdsc, &req->r_caps_reservation);

‎fs/ceph/mds_client.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ struct ceph_mds_reply_info_parsed {
7474
struct ceph_mds_reply_info_in *dir_in;
7575
u8 dir_complete, dir_end;
7676
};
77+
78+
/* for create results */
79+
struct {
80+
bool has_create_ino;
81+
u64 ino;
82+
};
7783
};
7884

7985
/* encoded blob describing snapshot contexts for certain

‎include/linux/ceph/ceph_features.h‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,19 @@
1414
#define CEPH_FEATURE_DIRLAYOUTHASH (1<<7)
1515
/* bits 8-17 defined by user-space; not supported yet here */
1616
#define CEPH_FEATURE_CRUSH_TUNABLES (1<<18)
17+
/* bits 19-24 defined by user-space; not supported yet here */
18+
#define CEPH_FEATURE_CRUSH_TUNABLES2 (1<<25)
19+
/* bit 26 defined by user-space; not supported yet here */
20+
#define CEPH_FEATURE_REPLY_CREATE_INODE (1<<27)
1721

1822
/*
1923
* Features supported.
2024
*/
2125
#define CEPH_FEATURES_SUPPORTED_DEFAULT \
2226
(CEPH_FEATURE_NOSRCADDR | \
23-
CEPH_FEATURE_CRUSH_TUNABLES)
27+
CEPH_FEATURE_CRUSH_TUNABLES | \
28+
CEPH_FEATURE_CRUSH_TUNABLES2 | \
29+
CEPH_FEATURE_REPLY_CREATE_INODE)
2430

2531
#define CEPH_FEATURES_REQUIRED_DEFAULT \
2632
(CEPH_FEATURE_NOSRCADDR)

‎include/linux/ceph/decode.h‎

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ static inline int ceph_has_room(void **p, void *end, size_t n)
5252
return end >= *p && n <= end - *p;
5353
}
5454

55-
#define ceph_decode_need(p, end, n, bad) \
56-
do { \
57-
if (!likely(ceph_has_room(p, end, n))) \
58-
goto bad; \
55+
#define ceph_decode_need(p, end, n, bad) \
56+
do { \
57+
if (!likely(ceph_has_room(p, end, n))) \
58+
goto bad; \
5959
} while (0)
6060

6161
#define ceph_decode_64_safe(p, end, v, bad) \
@@ -99,8 +99,8 @@ static inline int ceph_has_room(void **p, void *end, size_t n)
9999
*
100100
* There are two possible failures:
101101
* - converting the string would require accessing memory at or
102-
* beyond the "end" pointer provided (-E
103-
* - memory could not be allocated for the result
102+
* beyond the "end" pointer provided (-ERANGE)
103+
* - memory could not be allocated for the result (-ENOMEM)
104104
*/
105105
static inline char *ceph_extract_encoded_string(void **p, void *end,
106106
size_t *lenp, gfp_t gfp)
@@ -217,10 +217,10 @@ static inline void ceph_encode_string(void **p, void *end,
217217
*p += len;
218218
}
219219

220-
#define ceph_encode_need(p, end, n, bad) \
221-
do { \
222-
if (!likely(ceph_has_room(p, end, n))) \
223-
goto bad; \
220+
#define ceph_encode_need(p, end, n, bad) \
221+
do { \
222+
if (!likely(ceph_has_room(p, end, n))) \
223+
goto bad; \
224224
} while (0)
225225

226226
#define ceph_encode_64_safe(p, end, v, bad) \
@@ -231,12 +231,17 @@ static inline void ceph_encode_string(void **p, void *end,
231231
#define ceph_encode_32_safe(p, end, v, bad) \
232232
do { \
233233
ceph_encode_need(p, end, sizeof(u32), bad); \
234-
ceph_encode_32(p, v); \
234+
ceph_encode_32(p, v); \
235235
} while (0)
236236
#define ceph_encode_16_safe(p, end, v, bad) \
237237
do { \
238238
ceph_encode_need(p, end, sizeof(u16), bad); \
239-
ceph_encode_16(p, v); \
239+
ceph_encode_16(p, v); \
240+
} while (0)
241+
#define ceph_encode_8_safe(p, end, v, bad) \
242+
do { \
243+
ceph_encode_need(p, end, sizeof(u8), bad); \
244+
ceph_encode_8(p, v); \
240245
} while (0)
241246

242247
#define ceph_encode_copy_safe(p, end, pv, n, bad) \

‎include/linux/ceph/osd_client.h‎

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/ceph/osdmap.h>
1111
#include <linux/ceph/messenger.h>
1212
#include <linux/ceph/auth.h>
13+
#include <linux/ceph/pagelist.h>
1314

1415
/*
1516
* Maximum object name size
@@ -22,7 +23,6 @@ struct ceph_snap_context;
2223
struct ceph_osd_request;
2324
struct ceph_osd_client;
2425
struct ceph_authorizer;
25-
struct ceph_pagelist;
2626

2727
/*
2828
* completion callback for async writepages
@@ -95,7 +95,7 @@ struct ceph_osd_request {
9595
struct bio *r_bio; /* instead of pages */
9696
#endif
9797

98-
struct ceph_pagelist *r_trail; /* trailing part of the data */
98+
struct ceph_pagelist r_trail; /* trailing part of the data */
9999
};
100100

101101
struct ceph_osd_event {
@@ -157,7 +157,6 @@ struct ceph_osd_client {
157157

158158
struct ceph_osd_req_op {
159159
u16 op; /* CEPH_OSD_OP_* */
160-
u32 flags; /* CEPH_OSD_FLAG_* */
161160
union {
162161
struct {
163162
u64 offset, length;
@@ -207,29 +206,24 @@ extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc,
207206
extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc,
208207
struct ceph_msg *msg);
209208

210-
extern int ceph_calc_raw_layout(struct ceph_osd_client *osdc,
211-
struct ceph_file_layout *layout,
212-
u64 snapid,
209+
extern int ceph_calc_raw_layout(struct ceph_file_layout *layout,
213210
u64 off, u64 *plen, u64 *bno,
214211
struct ceph_osd_request *req,
215212
struct ceph_osd_req_op *op);
216213

217214
extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
218-
int flags,
219215
struct ceph_snap_context *snapc,
220-
struct ceph_osd_req_op *ops,
216+
unsigned int num_op,
221217
bool use_mempool,
222-
gfp_t gfp_flags,
223-
struct page **pages,
224-
struct bio *bio);
218+
gfp_t gfp_flags);
225219

226220
extern void ceph_osdc_build_request(struct ceph_osd_request *req,
227-
u64 off, u64 *plen,
221+
u64 off, u64 len,
222+
unsigned int num_op,
228223
struct ceph_osd_req_op *src_ops,
229224
struct ceph_snap_context *snapc,
230-
struct timespec *mtime,
231-
const char *oid,
232-
int oid_len);
225+
u64 snap_id,
226+
struct timespec *mtime);
233227

234228
extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *,
235229
struct ceph_file_layout *layout,

‎include/linux/ceph/osdmap.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ extern void ceph_osdmap_destroy(struct ceph_osdmap *map);
110110

111111
/* calculate mapping of a file extent to an object */
112112
extern int ceph_calc_file_object_mapping(struct ceph_file_layout *layout,
113-
u64 off, u64 *plen,
113+
u64 off, u64 len,
114114
u64 *bno, u64 *oxoff, u64 *oxlen);
115115

116116
/* calculate mapping of object to a placement group */

0 commit comments

Comments
 (0)