Skip to content

Commit 7c2a69f

Browse files
committed
Merge tag 'ceph-for-5.9-rc1' of git://github.com/ceph/ceph-client
Pull ceph updates from Ilya Dryomov: "Xiubo has completed his work on filesystem client metrics, they are sent to all available MDSes once per second now. Other than that, we have a lot of fixes and cleanups all around the filesystem, including a tweak to cut down on MDS request resends in multi-MDS setups from Yanhu and fixups for SELinux symlink labeling and MClientSession message decoding from Jeff" * tag 'ceph-for-5.9-rc1' of git://github.com/ceph/ceph-client: (22 commits) ceph: handle zero-length feature mask in session messages ceph: use frag's MDS in either mode ceph: move sb->wb_pagevec_pool to be a global mempool ceph: set sec_context xattr on symlink creation ceph: remove redundant initialization of variable mds ceph: fix use-after-free for fsc->mdsc ceph: remove unused variables in ceph_mdsmap_decode() ceph: delete repeated words in fs/ceph/ ceph: send client provided metric flags in client metadata ceph: periodically send perf metrics to MDSes ceph: check the sesion state and return false in case it is closed libceph: replace HTTP links with HTTPS ones ceph: remove unnecessary cast in kfree() libceph: just have osd_req_op_init() return a pointer ceph: do not access the kiocb after aio requests ceph: clean up and optimize ceph_check_delayed_caps() ceph: fix potential mdsc use-after-free crash ceph: switch to WARN_ON_ONCE in encode_supported_features() ceph: add global total_caps to count the mdsc's total caps number ceph: add check_session_state() helper and make it global ...
2 parents 7a02c8d + 02e3757 commit 7c2a69f

25 files changed

+511
-136
lines changed

fs/ceph/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ config CEPH_FS
1313
scalable file system designed to provide high performance,
1414
reliable access to petabytes of storage.
1515

16-
More information at http://ceph.newdream.net/.
16+
More information at https://ceph.io/.
1717

1818
If unsure, say N.
1919

fs/ceph/addr.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,7 @@ static void writepages_finish(struct ceph_osd_request *req)
862862

863863
osd_data = osd_req_op_extent_osd_data(req, 0);
864864
if (osd_data->pages_from_pool)
865-
mempool_free(osd_data->pages,
866-
ceph_sb_to_client(inode->i_sb)->wb_pagevec_pool);
865+
mempool_free(osd_data->pages, ceph_wb_pagevec_pool);
867866
else
868867
kfree(osd_data->pages);
869868
ceph_osdc_put_request(req);
@@ -955,10 +954,10 @@ static int ceph_writepages_start(struct address_space *mapping,
955954
int num_ops = 0, op_idx;
956955
unsigned i, pvec_pages, max_pages, locked_pages = 0;
957956
struct page **pages = NULL, **data_pages;
958-
mempool_t *pool = NULL; /* Becomes non-null if mempool used */
959957
struct page *page;
960958
pgoff_t strip_unit_end = 0;
961959
u64 offset = 0, len = 0;
960+
bool from_pool = false;
962961

963962
max_pages = wsize >> PAGE_SHIFT;
964963

@@ -1057,16 +1056,16 @@ static int ceph_writepages_start(struct address_space *mapping,
10571056
sizeof(*pages),
10581057
GFP_NOFS);
10591058
if (!pages) {
1060-
pool = fsc->wb_pagevec_pool;
1061-
pages = mempool_alloc(pool, GFP_NOFS);
1059+
from_pool = true;
1060+
pages = mempool_alloc(ceph_wb_pagevec_pool, GFP_NOFS);
10621061
BUG_ON(!pages);
10631062
}
10641063

10651064
len = 0;
10661065
} else if (page->index !=
10671066
(offset + len) >> PAGE_SHIFT) {
1068-
if (num_ops >= (pool ? CEPH_OSD_SLAB_OPS :
1069-
CEPH_OSD_MAX_OPS)) {
1067+
if (num_ops >= (from_pool ? CEPH_OSD_SLAB_OPS :
1068+
CEPH_OSD_MAX_OPS)) {
10701069
redirty_page_for_writepage(wbc, page);
10711070
unlock_page(page);
10721071
break;
@@ -1161,7 +1160,7 @@ static int ceph_writepages_start(struct address_space *mapping,
11611160
offset, len);
11621161
osd_req_op_extent_osd_data_pages(req, op_idx,
11631162
data_pages, len, 0,
1164-
!!pool, false);
1163+
from_pool, false);
11651164
osd_req_op_extent_update(req, op_idx, len);
11661165

11671166
len = 0;
@@ -1188,12 +1187,12 @@ static int ceph_writepages_start(struct address_space *mapping,
11881187
dout("writepages got pages at %llu~%llu\n", offset, len);
11891188

11901189
osd_req_op_extent_osd_data_pages(req, op_idx, data_pages, len,
1191-
0, !!pool, false);
1190+
0, from_pool, false);
11921191
osd_req_op_extent_update(req, op_idx, len);
11931192

11941193
BUG_ON(op_idx + 1 != req->r_num_ops);
11951194

1196-
pool = NULL;
1195+
from_pool = false;
11971196
if (i < locked_pages) {
11981197
BUG_ON(num_ops <= req->r_num_ops);
11991198
num_ops -= req->r_num_ops;
@@ -1204,8 +1203,8 @@ static int ceph_writepages_start(struct address_space *mapping,
12041203
pages = kmalloc_array(locked_pages, sizeof(*pages),
12051204
GFP_NOFS);
12061205
if (!pages) {
1207-
pool = fsc->wb_pagevec_pool;
1208-
pages = mempool_alloc(pool, GFP_NOFS);
1206+
from_pool = true;
1207+
pages = mempool_alloc(ceph_wb_pagevec_pool, GFP_NOFS);
12091208
BUG_ON(!pages);
12101209
}
12111210
memcpy(pages, data_pages + i,

fs/ceph/caps.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ void ceph_add_cap(struct inode *inode,
668668
spin_lock(&session->s_cap_lock);
669669
list_add_tail(&cap->session_caps, &session->s_caps);
670670
session->s_nr_caps++;
671+
atomic64_inc(&mdsc->metric.total_caps);
671672
spin_unlock(&session->s_cap_lock);
672673
} else {
673674
spin_lock(&session->s_cap_lock);
@@ -1161,6 +1162,7 @@ void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release)
11611162
} else {
11621163
list_del_init(&cap->session_caps);
11631164
session->s_nr_caps--;
1165+
atomic64_dec(&mdsc->metric.total_caps);
11641166
cap->session = NULL;
11651167
removed = 1;
11661168
}
@@ -4187,10 +4189,8 @@ void ceph_check_delayed_caps(struct ceph_mds_client *mdsc)
41874189
struct ceph_inode_info *ci;
41884190

41894191
dout("check_delayed_caps\n");
4190-
while (1) {
4191-
spin_lock(&mdsc->cap_delay_lock);
4192-
if (list_empty(&mdsc->cap_delay_list))
4193-
break;
4192+
spin_lock(&mdsc->cap_delay_lock);
4193+
while (!list_empty(&mdsc->cap_delay_list)) {
41944194
ci = list_first_entry(&mdsc->cap_delay_list,
41954195
struct ceph_inode_info,
41964196
i_cap_delay_list);
@@ -4200,13 +4200,13 @@ void ceph_check_delayed_caps(struct ceph_mds_client *mdsc)
42004200
list_del_init(&ci->i_cap_delay_list);
42014201

42024202
inode = igrab(&ci->vfs_inode);
4203-
spin_unlock(&mdsc->cap_delay_lock);
4204-
42054203
if (inode) {
4204+
spin_unlock(&mdsc->cap_delay_lock);
42064205
dout("check_delayed_caps on %p\n", inode);
42074206
ceph_check_caps(ci, 0, NULL);
42084207
/* avoid calling iput_final() in tick thread */
42094208
ceph_async_iput(inode);
4209+
spin_lock(&mdsc->cap_delay_lock);
42104210
}
42114211
}
42124212
spin_unlock(&mdsc->cap_delay_lock);

fs/ceph/debugfs.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static int metric_show(struct seq_file *s, void *p)
145145
struct ceph_fs_client *fsc = s->private;
146146
struct ceph_mds_client *mdsc = fsc->mdsc;
147147
struct ceph_client_metric *m = &mdsc->metric;
148-
int i, nr_caps = 0;
148+
int nr_caps = 0;
149149
s64 total, sum, avg, min, max, sq;
150150

151151
seq_printf(s, "item total avg_lat(us) min_lat(us) max_lat(us) stdev(us)\n");
@@ -190,17 +190,7 @@ static int metric_show(struct seq_file *s, void *p)
190190
percpu_counter_sum(&m->d_lease_mis),
191191
percpu_counter_sum(&m->d_lease_hit));
192192

193-
mutex_lock(&mdsc->mutex);
194-
for (i = 0; i < mdsc->max_sessions; i++) {
195-
struct ceph_mds_session *s;
196-
197-
s = __ceph_lookup_mds_session(mdsc, i);
198-
if (!s)
199-
continue;
200-
nr_caps += s->s_nr_caps;
201-
ceph_put_mds_session(s);
202-
}
203-
mutex_unlock(&mdsc->mutex);
193+
nr_caps = atomic64_read(&m->total_caps);
204194
seq_printf(s, "%-14s%-16d%-16lld%lld\n", "caps", nr_caps,
205195
percpu_counter_sum(&m->i_caps_mis),
206196
percpu_counter_sum(&m->i_caps_hit));
@@ -272,7 +262,7 @@ static int mds_sessions_show(struct seq_file *s, void *ptr)
272262
struct ceph_mds_client *mdsc = fsc->mdsc;
273263
struct ceph_auth_client *ac = fsc->client->monc.auth;
274264
struct ceph_options *opt = fsc->client->options;
275-
int mds = -1;
265+
int mds;
276266

277267
mutex_lock(&mdsc->mutex);
278268

fs/ceph/dir.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,10 @@ static int ceph_symlink(struct inode *dir, struct dentry *dentry,
930930
req->r_num_caps = 2;
931931
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL;
932932
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
933+
if (as_ctx.pagelist) {
934+
req->r_pagelist = as_ctx.pagelist;
935+
as_ctx.pagelist = NULL;
936+
}
933937
err = ceph_mdsc_do_request(mdsc, dir, req);
934938
if (!err && !req->r_reply_info.head->is_dentry)
935939
err = ceph_handle_notrace_create(dir, dentry);

fs/ceph/file.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,7 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to)
15381538
struct inode *inode = file_inode(filp);
15391539
struct ceph_inode_info *ci = ceph_inode(inode);
15401540
struct page *pinned_page = NULL;
1541+
bool direct_lock = iocb->ki_flags & IOCB_DIRECT;
15411542
ssize_t ret;
15421543
int want, got = 0;
15431544
int retry_op = 0, read = 0;
@@ -1546,7 +1547,7 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to)
15461547
dout("aio_read %p %llx.%llx %llu~%u trying to get caps on %p\n",
15471548
inode, ceph_vinop(inode), iocb->ki_pos, (unsigned)len, inode);
15481549

1549-
if (iocb->ki_flags & IOCB_DIRECT)
1550+
if (direct_lock)
15501551
ceph_start_io_direct(inode);
15511552
else
15521553
ceph_start_io_read(inode);
@@ -1603,7 +1604,7 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to)
16031604
}
16041605
ceph_put_cap_refs(ci, got);
16051606

1606-
if (iocb->ki_flags & IOCB_DIRECT)
1607+
if (direct_lock)
16071608
ceph_end_io_direct(inode);
16081609
else
16091610
ceph_end_io_read(inode);

0 commit comments

Comments
 (0)