Skip to content

Commit 31990f0

Browse files
committed
Merge tag 'ceph-for-4.20-rc1' of git://github.com/ceph/ceph-client
Pull ceph updates from Ilya Dryomov: "The highlights are: - a series that fixes some old memory allocation issues in libceph (myself). We no longer allocate memory in places where allocation failures cannot be handled and BUG when the allocation fails. - support for copy_file_range() syscall (Luis Henriques). If size and alignment conditions are met, it leverages RADOS copy-from operation. Otherwise, a local copy is performed. - a patch that reduces memory requirement of ceph_sync_read() from the size of the entire read to the size of one object (Zheng Yan). - fallocate() syscall is now restricted to FALLOC_FL_PUNCH_HOLE (Luis Henriques)" * tag 'ceph-for-4.20-rc1' of git://github.com/ceph/ceph-client: (25 commits) ceph: new mount option to disable usage of copy-from op ceph: support copy_file_range file operation libceph: support the RADOS copy-from operation ceph: add non-blocking parameter to ceph_try_get_caps() libceph: check reply num_data_items in setup_request_data() libceph: preallocate message data items libceph, rbd, ceph: move ceph_osdc_alloc_messages() calls libceph: introduce alloc_watch_request() libceph: assign cookies in linger_submit() libceph: enable fallback to ceph_msg_new() in ceph_msgpool_get() ceph: num_ops is off by one in ceph_aio_retry_work() libceph: no need to call osd_req_opcode_valid() in osd_req_encode_op() ceph: set timeout conditionally in __cap_delay_requeue libceph: don't consume a ref on pagelist in ceph_msg_data_add_pagelist() libceph: introduce ceph_pagelist_alloc() libceph: osd_req_op_cls_init() doesn't need to take opcode libceph: bump CEPH_MSG_MAX_DATA_LEN ceph: only allow punch hole mode in fallocate ceph: refactor ceph_sync_read() ceph: check if LOOKUPNAME request was aborted when filling trace ...
2 parents a9ac6cc + ea4cdc5 commit 31990f0

File tree

21 files changed

+900
-404
lines changed

21 files changed

+900
-404
lines changed

Documentation/filesystems/ceph.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ Mount Options
151151
Report overall filesystem usage in statfs instead of using the root
152152
directory quota.
153153

154+
nocopyfrom
155+
Don't use the RADOS 'copy-from' operation to perform remote object
156+
copies. Currently, it's only used in copy_file_range, which will revert
157+
to the default VFS implementation if this option is used.
158+
154159
More Information
155160
================
156161

drivers/block/rbd.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,9 +1500,6 @@ rbd_osd_req_create(struct rbd_obj_request *obj_req, unsigned int num_ops)
15001500
rbd_dev->header.object_prefix, obj_req->ex.oe_objno))
15011501
goto err_req;
15021502

1503-
if (ceph_osdc_alloc_messages(req, GFP_NOIO))
1504-
goto err_req;
1505-
15061503
return req;
15071504

15081505
err_req:
@@ -1945,6 +1942,10 @@ static int __rbd_img_fill_request(struct rbd_img_request *img_req)
19451942
}
19461943
if (ret)
19471944
return ret;
1945+
1946+
ret = ceph_osdc_alloc_messages(obj_req->osd_req, GFP_NOIO);
1947+
if (ret)
1948+
return ret;
19481949
}
19491950

19501951
return 0;
@@ -2374,8 +2375,7 @@ static int rbd_obj_issue_copyup(struct rbd_obj_request *obj_req, u32 bytes)
23742375
if (!obj_req->osd_req)
23752376
return -ENOMEM;
23762377

2377-
ret = osd_req_op_cls_init(obj_req->osd_req, 0, CEPH_OSD_OP_CALL, "rbd",
2378-
"copyup");
2378+
ret = osd_req_op_cls_init(obj_req->osd_req, 0, "rbd", "copyup");
23792379
if (ret)
23802380
return ret;
23812381

@@ -2405,6 +2405,10 @@ static int rbd_obj_issue_copyup(struct rbd_obj_request *obj_req, u32 bytes)
24052405
rbd_assert(0);
24062406
}
24072407

2408+
ret = ceph_osdc_alloc_messages(obj_req->osd_req, GFP_NOIO);
2409+
if (ret)
2410+
return ret;
2411+
24082412
rbd_obj_request_submit(obj_req);
24092413
return 0;
24102414
}
@@ -3784,10 +3788,6 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev,
37843788
ceph_oloc_copy(&req->r_base_oloc, oloc);
37853789
req->r_flags = CEPH_OSD_FLAG_READ;
37863790

3787-
ret = ceph_osdc_alloc_messages(req, GFP_KERNEL);
3788-
if (ret)
3789-
goto out_req;
3790-
37913791
pages = ceph_alloc_page_vector(num_pages, GFP_KERNEL);
37923792
if (IS_ERR(pages)) {
37933793
ret = PTR_ERR(pages);
@@ -3798,6 +3798,10 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev,
37983798
osd_req_op_extent_osd_data_pages(req, 0, pages, buf_len, 0, false,
37993799
true);
38003800

3801+
ret = ceph_osdc_alloc_messages(req, GFP_KERNEL);
3802+
if (ret)
3803+
goto out_req;
3804+
38013805
ceph_osdc_start_request(osdc, req, false);
38023806
ret = ceph_osdc_wait_request(osdc, req);
38033807
if (ret >= 0)
@@ -6067,7 +6071,7 @@ static ssize_t rbd_remove_single_major(struct bus_type *bus,
60676071
* create control files in sysfs
60686072
* /sys/bus/rbd/...
60696073
*/
6070-
static int rbd_sysfs_init(void)
6074+
static int __init rbd_sysfs_init(void)
60716075
{
60726076
int ret;
60736077

@@ -6082,13 +6086,13 @@ static int rbd_sysfs_init(void)
60826086
return ret;
60836087
}
60846088

6085-
static void rbd_sysfs_cleanup(void)
6089+
static void __exit rbd_sysfs_cleanup(void)
60866090
{
60876091
bus_unregister(&rbd_bus_type);
60886092
device_unregister(&rbd_root_dev);
60896093
}
60906094

6091-
static int rbd_slab_init(void)
6095+
static int __init rbd_slab_init(void)
60926096
{
60936097
rbd_assert(!rbd_img_request_cache);
60946098
rbd_img_request_cache = KMEM_CACHE(rbd_img_request, 0);

fs/ceph/acl.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)
104104
struct timespec64 old_ctime = inode->i_ctime;
105105
umode_t new_mode = inode->i_mode, old_mode = inode->i_mode;
106106

107+
if (ceph_snap(inode) != CEPH_NOSNAP) {
108+
ret = -EROFS;
109+
goto out;
110+
}
111+
107112
switch (type) {
108113
case ACL_TYPE_ACCESS:
109114
name = XATTR_NAME_POSIX_ACL_ACCESS;
@@ -138,11 +143,6 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)
138143
goto out_free;
139144
}
140145

141-
if (ceph_snap(inode) != CEPH_NOSNAP) {
142-
ret = -EROFS;
143-
goto out_free;
144-
}
145-
146146
if (new_mode != old_mode) {
147147
newattrs.ia_ctime = current_time(inode);
148148
newattrs.ia_mode = new_mode;
@@ -206,10 +206,9 @@ int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
206206
tmp_buf = kmalloc(max(val_size1, val_size2), GFP_KERNEL);
207207
if (!tmp_buf)
208208
goto out_err;
209-
pagelist = kmalloc(sizeof(struct ceph_pagelist), GFP_KERNEL);
209+
pagelist = ceph_pagelist_alloc(GFP_KERNEL);
210210
if (!pagelist)
211211
goto out_err;
212-
ceph_pagelist_init(pagelist);
213212

214213
err = ceph_pagelist_reserve(pagelist, PAGE_SIZE);
215214
if (err)

fs/ceph/addr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,
322322
/* caller of readpages does not hold buffer and read caps
323323
* (fadvise, madvise and readahead cases) */
324324
int want = CEPH_CAP_FILE_CACHE;
325-
ret = ceph_try_get_caps(ci, CEPH_CAP_FILE_RD, want, &got);
325+
ret = ceph_try_get_caps(ci, CEPH_CAP_FILE_RD, want, true, &got);
326326
if (ret < 0) {
327327
dout("start_read %p, error getting cap\n", inode);
328328
} else if (!(got & want)) {

fs/ceph/caps.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,9 @@ static void __cap_set_timeouts(struct ceph_mds_client *mdsc,
519519
* -> we take mdsc->cap_delay_lock
520520
*/
521521
static void __cap_delay_requeue(struct ceph_mds_client *mdsc,
522-
struct ceph_inode_info *ci)
522+
struct ceph_inode_info *ci,
523+
bool set_timeout)
523524
{
524-
__cap_set_timeouts(mdsc, ci);
525525
dout("__cap_delay_requeue %p flags %d at %lu\n", &ci->vfs_inode,
526526
ci->i_ceph_flags, ci->i_hold_caps_max);
527527
if (!mdsc->stopping) {
@@ -531,6 +531,8 @@ static void __cap_delay_requeue(struct ceph_mds_client *mdsc,
531531
goto no_change;
532532
list_del_init(&ci->i_cap_delay_list);
533533
}
534+
if (set_timeout)
535+
__cap_set_timeouts(mdsc, ci);
534536
list_add_tail(&ci->i_cap_delay_list, &mdsc->cap_delay_list);
535537
no_change:
536538
spin_unlock(&mdsc->cap_delay_lock);
@@ -720,7 +722,7 @@ void ceph_add_cap(struct inode *inode,
720722
dout(" issued %s, mds wanted %s, actual %s, queueing\n",
721723
ceph_cap_string(issued), ceph_cap_string(wanted),
722724
ceph_cap_string(actual_wanted));
723-
__cap_delay_requeue(mdsc, ci);
725+
__cap_delay_requeue(mdsc, ci, true);
724726
}
725727

726728
if (flags & CEPH_CAP_FLAG_AUTH) {
@@ -1647,7 +1649,7 @@ int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask,
16471649
if (((was | ci->i_flushing_caps) & CEPH_CAP_FILE_BUFFER) &&
16481650
(mask & CEPH_CAP_FILE_BUFFER))
16491651
dirty |= I_DIRTY_DATASYNC;
1650-
__cap_delay_requeue(mdsc, ci);
1652+
__cap_delay_requeue(mdsc, ci, true);
16511653
return dirty;
16521654
}
16531655

@@ -2065,7 +2067,7 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
20652067

20662068
/* Reschedule delayed caps release if we delayed anything */
20672069
if (delayed)
2068-
__cap_delay_requeue(mdsc, ci);
2070+
__cap_delay_requeue(mdsc, ci, false);
20692071

20702072
spin_unlock(&ci->i_ceph_lock);
20712073

@@ -2125,7 +2127,7 @@ static int try_flush_caps(struct inode *inode, u64 *ptid)
21252127

21262128
if (delayed) {
21272129
spin_lock(&ci->i_ceph_lock);
2128-
__cap_delay_requeue(mdsc, ci);
2130+
__cap_delay_requeue(mdsc, ci, true);
21292131
spin_unlock(&ci->i_ceph_lock);
21302132
}
21312133
} else {
@@ -2671,17 +2673,18 @@ static void check_max_size(struct inode *inode, loff_t endoff)
26712673
ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL);
26722674
}
26732675

2674-
int ceph_try_get_caps(struct ceph_inode_info *ci, int need, int want, int *got)
2676+
int ceph_try_get_caps(struct ceph_inode_info *ci, int need, int want,
2677+
bool nonblock, int *got)
26752678
{
26762679
int ret, err = 0;
26772680

26782681
BUG_ON(need & ~CEPH_CAP_FILE_RD);
2679-
BUG_ON(want & ~(CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO));
2682+
BUG_ON(want & ~(CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO|CEPH_CAP_FILE_SHARED));
26802683
ret = ceph_pool_perm_check(ci, need);
26812684
if (ret < 0)
26822685
return ret;
26832686

2684-
ret = try_get_cap_refs(ci, need, want, 0, true, got, &err);
2687+
ret = try_get_cap_refs(ci, need, want, 0, nonblock, got, &err);
26852688
if (ret) {
26862689
if (err == -EAGAIN) {
26872690
ret = 0;

0 commit comments

Comments
 (0)