Skip to content

Commit 4c46bef

Browse files
committed
Merge tag 'ceph-for-5.6-rc1' of https://github.com/ceph/ceph-client
Pull ceph fixes from Ilya Dryomov: - a set of patches that fixes various corner cases in mount and umount code (Xiubo Li). This has to do with choosing an MDS, distinguishing between laggy and down MDSes and parsing the server path. - inode initialization fixes (Jeff Layton). The one included here mostly concerns things like open_by_handle() and there is another one that will come through Al. - copy_file_range() now uses the new copy-from2 op (Luis Henriques). The existing copy-from op turned out to be infeasible for generic filesystem use; we disable the copy offload if OSDs don't support copy-from2. - a patch to link "rbd" and "block" devices together in sysfs (Hannes Reinecke) ... and a smattering of cleanups from Xiubo, Jeff and Chengguang. * tag 'ceph-for-5.6-rc1' of https://github.com/ceph/ceph-client: (25 commits) rbd: set the 'device' link in sysfs ceph: move net/ceph/ceph_fs.c to fs/ceph/util.c ceph: print name of xattr in __ceph_{get,set}xattr() douts ceph: print r_direct_hash in hex in __choose_mds() dout ceph: use copy-from2 op in copy_file_range ceph: close holes in structs ceph_mds_session and ceph_mds_request rbd: work around -Wuninitialized warning ceph: allocate the correct amount of extra bytes for the session features ceph: rename get_session and switch to use ceph_get_mds_session ceph: remove the extra slashes in the server path ceph: add possible_max_rank and make the code more readable ceph: print dentry offset in hex and fix xattr_version type ceph: only touch the caps which have the subset mask requested ceph: don't clear I_NEW until inode metadata is fully populated ceph: retry the same mds later after the new session is opened ceph: check availability of mds cluster on mount after wait timeout ceph: keep the session state until it is released ceph: add __send_request helper ceph: ensure we have a new cap before continuing in fill_inode ceph: drop unused ttl_from parameter from fill_inode ...
2 parents 5b21115 + 3325322 commit 4c46bef

File tree

20 files changed

+360
-193
lines changed

20 files changed

+360
-193
lines changed

drivers/block/rbd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2662,7 +2662,7 @@ static int rbd_img_fill_nodata(struct rbd_img_request *img_req,
26622662
u64 off, u64 len)
26632663
{
26642664
struct ceph_file_extent ex = { off, len };
2665-
union rbd_img_fill_iter dummy;
2665+
union rbd_img_fill_iter dummy = {};
26662666
struct rbd_img_fill_ctx fctx = {
26672667
.pos_type = OBJ_REQUEST_NODATA,
26682668
.pos = &dummy,
@@ -7143,7 +7143,7 @@ static ssize_t do_rbd_add(struct bus_type *bus,
71437143
if (rc)
71447144
goto err_out_image_lock;
71457145

7146-
add_disk(rbd_dev->disk);
7146+
device_add_disk(&rbd_dev->dev, rbd_dev->disk, NULL);
71477147
/* see rbd_init_disk() */
71487148
blk_put_queue(rbd_dev->disk->queue);
71497149

fs/ceph/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ obj-$(CONFIG_CEPH_FS) += ceph.o
88
ceph-y := super.o inode.o dir.o file.o locks.o addr.o ioctl.o \
99
export.o caps.o snap.o xattr.o quota.o io.o \
1010
mds_client.o mdsmap.o strings.o ceph_frag.o \
11-
debugfs.o
11+
debugfs.o util.o
1212

1313
ceph-$(CONFIG_CEPH_FSCACHE) += cache.o
1414
ceph-$(CONFIG_CEPH_FS_POSIX_ACL) += acl.o

fs/ceph/acl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
222222
err = ceph_pagelist_reserve(pagelist, len + val_size2 + 8);
223223
if (err)
224224
goto out_err;
225-
err = ceph_pagelist_encode_string(pagelist,
226-
XATTR_NAME_POSIX_ACL_DEFAULT, len);
225+
ceph_pagelist_encode_string(pagelist,
226+
XATTR_NAME_POSIX_ACL_DEFAULT, len);
227227
err = posix_acl_to_xattr(&init_user_ns, default_acl,
228228
tmp_buf, val_size2);
229229
if (err < 0)

fs/ceph/caps.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,8 @@ int __ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask, int touch)
908908
ci_node);
909909
if (!__cap_is_valid(cap))
910910
continue;
911-
__touch_cap(cap);
911+
if (cap->issued & mask)
912+
__touch_cap(cap);
912913
}
913914
}
914915
return 1;

fs/ceph/debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static int mdsmap_show(struct seq_file *s, void *p)
3333
seq_printf(s, "max_mds %d\n", mdsmap->m_max_mds);
3434
seq_printf(s, "session_timeout %d\n", mdsmap->m_session_timeout);
3535
seq_printf(s, "session_autoclose %d\n", mdsmap->m_session_autoclose);
36-
for (i = 0; i < mdsmap->m_num_mds; i++) {
36+
for (i = 0; i < mdsmap->possible_max_rank; i++) {
3737
struct ceph_entity_addr *addr = &mdsmap->m_info[i].addr;
3838
int state = mdsmap->m_info[i].state;
3939
seq_printf(s, "\tmds%d\t%s\t(%s)\n", i,

fs/ceph/dir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ void __ceph_dentry_dir_lease_touch(struct ceph_dentry_info *di)
11861186
struct dentry *dn = di->dentry;
11871187
struct ceph_mds_client *mdsc;
11881188

1189-
dout("dentry_dir_lease_touch %p %p '%pd' (offset %lld)\n",
1189+
dout("dentry_dir_lease_touch %p %p '%pd' (offset 0x%llx)\n",
11901190
di, dn, dn, di->offset);
11911191

11921192
if (!list_empty(&di->lease_list)) {
@@ -1567,7 +1567,7 @@ static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags)
15671567
inode = d_inode(dentry);
15681568
}
15691569

1570-
dout("d_revalidate %p '%pd' inode %p offset %lld\n", dentry,
1570+
dout("d_revalidate %p '%pd' inode %p offset 0x%llx\n", dentry,
15711571
dentry, inode, ceph_dentry(dentry)->offset);
15721572

15731573
/* always trust cached snapped dentries, snapdir dentry */

fs/ceph/file.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,9 @@ static ssize_t __ceph_copy_file_range(struct file *src_file, loff_t src_off,
19741974
if (ceph_test_mount_opt(src_fsc, NOCOPYFROM))
19751975
return -EOPNOTSUPP;
19761976

1977+
if (!src_fsc->have_copy_from2)
1978+
return -EOPNOTSUPP;
1979+
19771980
/*
19781981
* Striped file layouts require that we copy partial objects, but the
19791982
* OSD copy-from operation only supports full-object copies. Limit
@@ -2101,8 +2104,14 @@ static ssize_t __ceph_copy_file_range(struct file *src_file, loff_t src_off,
21012104
CEPH_OSD_OP_FLAG_FADVISE_NOCACHE,
21022105
&dst_oid, &dst_oloc,
21032106
CEPH_OSD_OP_FLAG_FADVISE_SEQUENTIAL |
2104-
CEPH_OSD_OP_FLAG_FADVISE_DONTNEED, 0);
2107+
CEPH_OSD_OP_FLAG_FADVISE_DONTNEED,
2108+
dst_ci->i_truncate_seq, dst_ci->i_truncate_size,
2109+
CEPH_OSD_COPY_FROM_FLAG_TRUNCATE_SEQ);
21052110
if (err) {
2111+
if (err == -EOPNOTSUPP) {
2112+
src_fsc->have_copy_from2 = false;
2113+
pr_notice("OSDs don't support copy-from2; disabling copy offload\n");
2114+
}
21062115
dout("ceph_osdc_copy_from returned %d\n", err);
21072116
if (!ret)
21082117
ret = err;

fs/ceph/inode.c

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ struct inode *ceph_get_inode(struct super_block *sb, struct ceph_vino vino)
5555
inode = iget5_locked(sb, t, ceph_ino_compare, ceph_set_ino_cb, &vino);
5656
if (!inode)
5757
return ERR_PTR(-ENOMEM);
58-
if (inode->i_state & I_NEW) {
58+
if (inode->i_state & I_NEW)
5959
dout("get_inode created new inode %p %llx.%llx ino %llx\n",
6060
inode, ceph_vinop(inode), (u64)inode->i_ino);
61-
unlock_new_inode(inode);
62-
}
6361

6462
dout("get_inode on %lu=%llx.%llx got %p\n", inode->i_ino, vino.ino,
6563
vino.snap, inode);
@@ -88,6 +86,10 @@ struct inode *ceph_get_snapdir(struct inode *parent)
8886
inode->i_fop = &ceph_snapdir_fops;
8987
ci->i_snap_caps = CEPH_CAP_PIN; /* so we can open */
9088
ci->i_rbytes = 0;
89+
90+
if (inode->i_state & I_NEW)
91+
unlock_new_inode(inode);
92+
9193
return inode;
9294
}
9395

@@ -728,8 +730,7 @@ void ceph_fill_file_time(struct inode *inode, int issued,
728730
static int fill_inode(struct inode *inode, struct page *locked_page,
729731
struct ceph_mds_reply_info_in *iinfo,
730732
struct ceph_mds_reply_dirfrag *dirinfo,
731-
struct ceph_mds_session *session,
732-
unsigned long ttl_from, int cap_fmode,
733+
struct ceph_mds_session *session, int cap_fmode,
733734
struct ceph_cap_reservation *caps_reservation)
734735
{
735736
struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
@@ -754,8 +755,11 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
754755
info_caps = le32_to_cpu(info->cap.caps);
755756

756757
/* prealloc new cap struct */
757-
if (info_caps && ceph_snap(inode) == CEPH_NOSNAP)
758+
if (info_caps && ceph_snap(inode) == CEPH_NOSNAP) {
758759
new_cap = ceph_get_cap(mdsc, caps_reservation);
760+
if (!new_cap)
761+
return -ENOMEM;
762+
}
759763

760764
/*
761765
* prealloc xattr data, if it looks like we'll need it. only
@@ -1237,7 +1241,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req)
12371241
if (dir) {
12381242
err = fill_inode(dir, NULL,
12391243
&rinfo->diri, rinfo->dirfrag,
1240-
session, req->r_request_started, -1,
1244+
session, -1,
12411245
&req->r_caps_reservation);
12421246
if (err < 0)
12431247
goto done;
@@ -1302,18 +1306,22 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req)
13021306
err = PTR_ERR(in);
13031307
goto done;
13041308
}
1305-
req->r_target_inode = in;
13061309

13071310
err = fill_inode(in, req->r_locked_page, &rinfo->targeti, NULL,
1308-
session, req->r_request_started,
1311+
session,
13091312
(!test_bit(CEPH_MDS_R_ABORTED, &req->r_req_flags) &&
1310-
rinfo->head->result == 0) ? req->r_fmode : -1,
1313+
rinfo->head->result == 0) ? req->r_fmode : -1,
13111314
&req->r_caps_reservation);
13121315
if (err < 0) {
13131316
pr_err("fill_inode badness %p %llx.%llx\n",
13141317
in, ceph_vinop(in));
1318+
if (in->i_state & I_NEW)
1319+
discard_new_inode(in);
13151320
goto done;
13161321
}
1322+
req->r_target_inode = in;
1323+
if (in->i_state & I_NEW)
1324+
unlock_new_inode(in);
13171325
}
13181326

13191327
/*
@@ -1493,12 +1501,18 @@ static int readdir_prepopulate_inodes_only(struct ceph_mds_request *req,
14931501
continue;
14941502
}
14951503
rc = fill_inode(in, NULL, &rde->inode, NULL, session,
1496-
req->r_request_started, -1,
1497-
&req->r_caps_reservation);
1504+
-1, &req->r_caps_reservation);
14981505
if (rc < 0) {
14991506
pr_err("fill_inode badness on %p got %d\n", in, rc);
15001507
err = rc;
1508+
if (in->i_state & I_NEW) {
1509+
ihold(in);
1510+
discard_new_inode(in);
1511+
}
1512+
} else if (in->i_state & I_NEW) {
1513+
unlock_new_inode(in);
15011514
}
1515+
15021516
/* avoid calling iput_final() in mds dispatch threads */
15031517
ceph_async_iput(in);
15041518
}
@@ -1694,19 +1708,24 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req,
16941708
}
16951709

16961710
ret = fill_inode(in, NULL, &rde->inode, NULL, session,
1697-
req->r_request_started, -1,
1698-
&req->r_caps_reservation);
1711+
-1, &req->r_caps_reservation);
16991712
if (ret < 0) {
17001713
pr_err("fill_inode badness on %p\n", in);
17011714
if (d_really_is_negative(dn)) {
17021715
/* avoid calling iput_final() in mds
17031716
* dispatch threads */
1717+
if (in->i_state & I_NEW) {
1718+
ihold(in);
1719+
discard_new_inode(in);
1720+
}
17041721
ceph_async_iput(in);
17051722
}
17061723
d_drop(dn);
17071724
err = ret;
17081725
goto next_item;
17091726
}
1727+
if (in->i_state & I_NEW)
1728+
unlock_new_inode(in);
17101729

17111730
if (d_really_is_negative(dn)) {
17121731
if (ceph_security_xattr_deadlock(in)) {

0 commit comments

Comments
 (0)