Skip to content

Commit 59331c2

Browse files
committed
Merge tag 'ceph-for-4.10-rc1' of git://github.com/ceph/ceph-client
Pull ceph updates from Ilya Dryomov: "A varied set of changes: - a large rework of cephx auth code to cope with CONFIG_VMAP_STACK (myself). Also fixed a deadlock caused by a bogus allocation on the writeback path and authorize reply verification. - a fix for long stalls during fsync (Jeff Layton). The client now has a way to force the MDS log flush, leading to ~100x speedups in some synthetic tests. - a new [no]require_active_mds mount option (Zheng Yan). On mount, we will now check whether any of the MDSes are available and bail rather than block if none are. This check can be avoided by specifying the "no" option. - a couple of MDS cap handling fixes and a few assorted patches throughout" * tag 'ceph-for-4.10-rc1' of git://github.com/ceph/ceph-client: (32 commits) libceph: remove now unused finish_request() wrapper libceph: always signal completion when done ceph: avoid creating orphan object when checking pool permission ceph: properly set issue_seq for cap release ceph: add flags parameter to send_cap_msg ceph: update cap message struct version to 10 ceph: define new argument structure for send_cap_msg ceph: move xattr initialzation before the encoding past the ceph_mds_caps ceph: fix minor typo in unsafe_request_wait ceph: record truncate size/seq for snap data writeback ceph: check availability of mds cluster on mount ceph: fix splice read for no Fc capability case ceph: try getting buffer capability for readahead/fadvise ceph: fix scheduler warning due to nested blocking ceph: fix printing wrong return variable in ceph_direct_read_write() crush: include mapper.h in mapper.c rbd: silence bogus -Wmaybe-uninitialized warning libceph: no need to drop con->mutex for ->get_authorizer() libceph: drop len argument of *verify_authorizer_reply() libceph: verify authorize reply on connect ...
2 parents ff0f962 + 45ee2c1 commit 59331c2

23 files changed

Lines changed: 809 additions & 724 deletions

File tree

‎drivers/block/rbd.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3756,7 +3756,7 @@ static void rbd_watch_cb(void *arg, u64 notify_id, u64 cookie,
37563756
struct rbd_device *rbd_dev = arg;
37573757
void *p = data;
37583758
void *const end = p + data_len;
3759-
u8 struct_v;
3759+
u8 struct_v = 0;
37603760
u32 len;
37613761
u32 notify_op;
37623762
int ret;

‎fs/ceph/addr.c‎

Lines changed: 75 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,32 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
315315
struct page **pages;
316316
pgoff_t next_index;
317317
int nr_pages = 0;
318-
int ret;
318+
int got = 0;
319+
int ret = 0;
320+
321+
if (!current->journal_info) {
322+
/* caller of readpages does not hold buffer and read caps
323+
* (fadvise, madvise and readahead cases) */
324+
int want = CEPH_CAP_FILE_CACHE;
325+
ret = ceph_try_get_caps(ci, CEPH_CAP_FILE_RD, want, &got);
326+
if (ret < 0) {
327+
dout("start_read %p, error getting cap\n", inode);
328+
} else if (!(got & want)) {
329+
dout("start_read %p, no cache cap\n", inode);
330+
ret = 0;
331+
}
332+
if (ret <= 0) {
333+
if (got)
334+
ceph_put_cap_refs(ci, got);
335+
while (!list_empty(page_list)) {
336+
page = list_entry(page_list->prev,
337+
struct page, lru);
338+
list_del(&page->lru);
339+
put_page(page);
340+
}
341+
return ret;
342+
}
343+
}
319344

320345
off = (u64) page_offset(page);
321346

@@ -338,15 +363,18 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
338363
CEPH_OSD_FLAG_READ, NULL,
339364
ci->i_truncate_seq, ci->i_truncate_size,
340365
false);
341-
if (IS_ERR(req))
342-
return PTR_ERR(req);
366+
if (IS_ERR(req)) {
367+
ret = PTR_ERR(req);
368+
goto out;
369+
}
343370

344371
/* build page vector */
345372
nr_pages = calc_pages_for(0, len);
346373
pages = kmalloc(sizeof(*pages) * nr_pages, GFP_KERNEL);
347-
ret = -ENOMEM;
348-
if (!pages)
349-
goto out;
374+
if (!pages) {
375+
ret = -ENOMEM;
376+
goto out_put;
377+
}
350378
for (i = 0; i < nr_pages; ++i) {
351379
page = list_entry(page_list->prev, struct page, lru);
352380
BUG_ON(PageLocked(page));
@@ -378,6 +406,12 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
378406
if (ret < 0)
379407
goto out_pages;
380408
ceph_osdc_put_request(req);
409+
410+
/* After adding locked pages to page cache, the inode holds cache cap.
411+
* So we can drop our cap refs. */
412+
if (got)
413+
ceph_put_cap_refs(ci, got);
414+
381415
return nr_pages;
382416

383417
out_pages:
@@ -386,8 +420,11 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
386420
unlock_page(pages[i]);
387421
}
388422
ceph_put_page_vector(pages, nr_pages, false);
389-
out:
423+
out_put:
390424
ceph_osdc_put_request(req);
425+
out:
426+
if (got)
427+
ceph_put_cap_refs(ci, got);
391428
return ret;
392429
}
393430

@@ -424,7 +461,6 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
424461
rc = start_read(inode, page_list, max);
425462
if (rc < 0)
426463
goto out;
427-
BUG_ON(rc == 0);
428464
}
429465
out:
430466
ceph_fscache_readpages_cancel(inode, page_list);
@@ -438,7 +474,9 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
438474
* only snap context we are allowed to write back.
439475
*/
440476
static struct ceph_snap_context *get_oldest_context(struct inode *inode,
441-
loff_t *snap_size)
477+
loff_t *snap_size,
478+
u64 *truncate_size,
479+
u32 *truncate_seq)
442480
{
443481
struct ceph_inode_info *ci = ceph_inode(inode);
444482
struct ceph_snap_context *snapc = NULL;
@@ -452,13 +490,21 @@ static struct ceph_snap_context *get_oldest_context(struct inode *inode,
452490
snapc = ceph_get_snap_context(capsnap->context);
453491
if (snap_size)
454492
*snap_size = capsnap->size;
493+
if (truncate_size)
494+
*truncate_size = capsnap->truncate_size;
495+
if (truncate_seq)
496+
*truncate_seq = capsnap->truncate_seq;
455497
break;
456498
}
457499
}
458500
if (!snapc && ci->i_wrbuffer_ref_head) {
459501
snapc = ceph_get_snap_context(ci->i_head_snapc);
460502
dout(" head snapc %p has %d dirty pages\n",
461503
snapc, ci->i_wrbuffer_ref_head);
504+
if (truncate_size)
505+
*truncate_size = capsnap->truncate_size;
506+
if (truncate_seq)
507+
*truncate_seq = capsnap->truncate_seq;
462508
}
463509
spin_unlock(&ci->i_ceph_lock);
464510
return snapc;
@@ -501,7 +547,8 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
501547
dout("writepage %p page %p not dirty?\n", inode, page);
502548
goto out;
503549
}
504-
oldest = get_oldest_context(inode, &snap_size);
550+
oldest = get_oldest_context(inode, &snap_size,
551+
&truncate_size, &truncate_seq);
505552
if (snapc->seq > oldest->seq) {
506553
dout("writepage %p page %p snapc %p not writeable - noop\n",
507554
inode, page, snapc);
@@ -512,12 +559,8 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
512559
}
513560
ceph_put_snap_context(oldest);
514561

515-
spin_lock(&ci->i_ceph_lock);
516-
truncate_seq = ci->i_truncate_seq;
517-
truncate_size = ci->i_truncate_size;
518562
if (snap_size == -1)
519563
snap_size = i_size_read(inode);
520-
spin_unlock(&ci->i_ceph_lock);
521564

522565
/* is this a partial page at end of file? */
523566
if (page_off >= snap_size) {
@@ -764,7 +807,8 @@ static int ceph_writepages_start(struct address_space *mapping,
764807
/* find oldest snap context with dirty data */
765808
ceph_put_snap_context(snapc);
766809
snap_size = -1;
767-
snapc = get_oldest_context(inode, &snap_size);
810+
snapc = get_oldest_context(inode, &snap_size,
811+
&truncate_size, &truncate_seq);
768812
if (!snapc) {
769813
/* hmm, why does writepages get called when there
770814
is no dirty data? */
@@ -774,11 +818,7 @@ static int ceph_writepages_start(struct address_space *mapping,
774818
dout(" oldest snapc is %p seq %lld (%d snaps)\n",
775819
snapc, snapc->seq, snapc->num_snaps);
776820

777-
spin_lock(&ci->i_ceph_lock);
778-
truncate_seq = ci->i_truncate_seq;
779-
truncate_size = ci->i_truncate_size;
780821
i_size = i_size_read(inode);
781-
spin_unlock(&ci->i_ceph_lock);
782822

783823
if (last_snapc && snapc != last_snapc) {
784824
/* if we switched to a newer snapc, restart our scan at the
@@ -1124,7 +1164,8 @@ static int ceph_writepages_start(struct address_space *mapping,
11241164
static int context_is_writeable_or_written(struct inode *inode,
11251165
struct ceph_snap_context *snapc)
11261166
{
1127-
struct ceph_snap_context *oldest = get_oldest_context(inode, NULL);
1167+
struct ceph_snap_context *oldest = get_oldest_context(inode, NULL,
1168+
NULL, NULL);
11281169
int ret = !oldest || snapc->seq <= oldest->seq;
11291170

11301171
ceph_put_snap_context(oldest);
@@ -1169,7 +1210,7 @@ static int ceph_update_writeable_page(struct file *file,
11691210
* this page is already dirty in another (older) snap
11701211
* context! is it writeable now?
11711212
*/
1172-
oldest = get_oldest_context(inode, NULL);
1213+
oldest = get_oldest_context(inode, NULL, NULL, NULL);
11731214

11741215
if (snapc->seq > oldest->seq) {
11751216
ceph_put_snap_context(oldest);
@@ -1371,9 +1412,11 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
13711412
inode, off, (size_t)PAGE_SIZE, ceph_cap_string(got));
13721413

13731414
if ((got & (CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO)) ||
1374-
ci->i_inline_version == CEPH_INLINE_NONE)
1415+
ci->i_inline_version == CEPH_INLINE_NONE) {
1416+
current->journal_info = vma->vm_file;
13751417
ret = filemap_fault(vma, vmf);
1376-
else
1418+
current->journal_info = NULL;
1419+
} else
13771420
ret = -EAGAIN;
13781421

13791422
dout("filemap_fault %p %llu~%zd dropping cap refs on %s ret %d\n",
@@ -1905,6 +1948,15 @@ int ceph_pool_perm_check(struct ceph_inode_info *ci, int need)
19051948
struct ceph_string *pool_ns;
19061949
int ret, flags;
19071950

1951+
if (ci->i_vino.snap != CEPH_NOSNAP) {
1952+
/*
1953+
* Pool permission check needs to write to the first object.
1954+
* But for snapshot, head of the first object may have alread
1955+
* been deleted. Skip check to avoid creating orphan object.
1956+
*/
1957+
return 0;
1958+
}
1959+
19081960
if (ceph_test_mount_opt(ceph_inode_to_client(&ci->vfs_inode),
19091961
NOPOOLPERM))
19101962
return 0;

0 commit comments

Comments
 (0)