Skip to content

Commit 9e95dae

Browse files
committed
Merge tag 'ceph-for-4.16-rc1' of git://github.com/ceph/ceph-client
Pull ceph updates from Ilya Dryomov: "Things have been very quiet on the rbd side, as work continues on the big ticket items slated for the next merge window. On the CephFS side we have a large number of cap handling improvements, a fix for our long-standing abuse of ->journal_info in ceph_readpages() and yet another dentry pointer management patch" * tag 'ceph-for-4.16-rc1' of git://github.com/ceph/ceph-client: ceph: improving efficiency of syncfs libceph: check kstrndup() return value ceph: try to allocate enough memory for reserved caps ceph: fix race of queuing delayed caps ceph: delete unreachable code in ceph_check_caps() ceph: limit rate of cap import/export error messages ceph: fix incorrect snaprealm when adding caps ceph: fix un-balanced fsc->writeback_count update ceph: track read contexts in ceph_file_info ceph: avoid dereferencing invalid pointer during cached readdir ceph: use atomic_t for ceph_inode_info::i_shared_gen ceph: cleanup traceless reply handling for rename ceph: voluntarily drop Fx cap for readdir request ceph: properly drop caps for setattr request ceph: voluntarily drop Lx cap for link/rename requests ceph: voluntarily drop Ax cap for requests that create new inode rbd: whitelist RBD_FEATURE_OPERATIONS feature bit rbd: don't NULL out ->obj_request in rbd_img_obj_parent_read_full() rbd: use kmem_cache_zalloc() in rbd_img_request_create() rbd: obj_request->completion is unused
2 parents a8c6db0 + 16515a6 commit 9e95dae

File tree

11 files changed

+323
-145
lines changed

11 files changed

+323
-145
lines changed

drivers/block/rbd.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,13 @@ static int atomic_dec_return_safe(atomic_t *v)
124124
#define RBD_FEATURE_STRIPINGV2 (1ULL<<1)
125125
#define RBD_FEATURE_EXCLUSIVE_LOCK (1ULL<<2)
126126
#define RBD_FEATURE_DATA_POOL (1ULL<<7)
127+
#define RBD_FEATURE_OPERATIONS (1ULL<<8)
127128

128129
#define RBD_FEATURES_ALL (RBD_FEATURE_LAYERING | \
129130
RBD_FEATURE_STRIPINGV2 | \
130131
RBD_FEATURE_EXCLUSIVE_LOCK | \
131-
RBD_FEATURE_DATA_POOL)
132+
RBD_FEATURE_DATA_POOL | \
133+
RBD_FEATURE_OPERATIONS)
132134

133135
/* Features supported by this (client software) implementation. */
134136

@@ -281,7 +283,6 @@ struct rbd_obj_request {
281283
int result;
282284

283285
rbd_obj_callback_t callback;
284-
struct completion completion;
285286

286287
struct kref kref;
287288
};
@@ -1734,10 +1735,7 @@ static void rbd_obj_request_complete(struct rbd_obj_request *obj_request)
17341735
{
17351736
dout("%s: obj %p cb %p\n", __func__, obj_request,
17361737
obj_request->callback);
1737-
if (obj_request->callback)
1738-
obj_request->callback(obj_request);
1739-
else
1740-
complete_all(&obj_request->completion);
1738+
obj_request->callback(obj_request);
17411739
}
17421740

17431741
static void rbd_obj_request_error(struct rbd_obj_request *obj_request, int err)
@@ -2013,7 +2011,6 @@ rbd_obj_request_create(enum obj_request_type type)
20132011
obj_request->which = BAD_WHICH;
20142012
obj_request->type = type;
20152013
INIT_LIST_HEAD(&obj_request->links);
2016-
init_completion(&obj_request->completion);
20172014
kref_init(&obj_request->kref);
20182015

20192016
dout("%s %p\n", __func__, obj_request);
@@ -2129,15 +2126,13 @@ static struct rbd_img_request *rbd_img_request_create(
21292126
{
21302127
struct rbd_img_request *img_request;
21312128

2132-
img_request = kmem_cache_alloc(rbd_img_request_cache, GFP_NOIO);
2129+
img_request = kmem_cache_zalloc(rbd_img_request_cache, GFP_NOIO);
21332130
if (!img_request)
21342131
return NULL;
21352132

2136-
img_request->rq = NULL;
21372133
img_request->rbd_dev = rbd_dev;
21382134
img_request->offset = offset;
21392135
img_request->length = length;
2140-
img_request->flags = 0;
21412136
if (op_type == OBJ_OP_DISCARD) {
21422137
img_request_discard_set(img_request);
21432138
img_request->snapc = snapc;
@@ -2149,11 +2144,8 @@ static struct rbd_img_request *rbd_img_request_create(
21492144
}
21502145
if (rbd_dev_parent_get(rbd_dev))
21512146
img_request_layered_set(img_request);
2147+
21522148
spin_lock_init(&img_request->completion_lock);
2153-
img_request->next_completion = 0;
2154-
img_request->callback = NULL;
2155-
img_request->result = 0;
2156-
img_request->obj_request_count = 0;
21572149
INIT_LIST_HEAD(&img_request->obj_requests);
21582150
kref_init(&img_request->kref);
21592151

@@ -2692,8 +2684,6 @@ static int rbd_img_obj_parent_read_full(struct rbd_obj_request *obj_request)
26922684

26932685
parent_request->copyup_pages = NULL;
26942686
parent_request->copyup_page_count = 0;
2695-
parent_request->obj_request = NULL;
2696-
rbd_obj_request_put(obj_request);
26972687
out_err:
26982688
if (pages)
26992689
ceph_release_page_vector(pages, page_count);

fs/ceph/addr.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ static void finish_read(struct ceph_osd_request *req)
299299
* start an async read(ahead) operation. return nr_pages we submitted
300300
* a read for on success, or negative error code.
301301
*/
302-
static int start_read(struct inode *inode, struct list_head *page_list, int max)
302+
static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,
303+
struct list_head *page_list, int max)
303304
{
304305
struct ceph_osd_client *osdc =
305306
&ceph_inode_to_client(inode)->client->osdc;
@@ -316,7 +317,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
316317
int got = 0;
317318
int ret = 0;
318319

319-
if (!current->journal_info) {
320+
if (!rw_ctx) {
320321
/* caller of readpages does not hold buffer and read caps
321322
* (fadvise, madvise and readahead cases) */
322323
int want = CEPH_CAP_FILE_CACHE;
@@ -437,6 +438,8 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
437438
{
438439
struct inode *inode = file_inode(file);
439440
struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
441+
struct ceph_file_info *ci = file->private_data;
442+
struct ceph_rw_context *rw_ctx;
440443
int rc = 0;
441444
int max = 0;
442445

@@ -449,11 +452,12 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
449452
if (rc == 0)
450453
goto out;
451454

455+
rw_ctx = ceph_find_rw_context(ci);
452456
max = fsc->mount_options->rsize >> PAGE_SHIFT;
453-
dout("readpages %p file %p nr_pages %d max %d\n",
454-
inode, file, nr_pages, max);
457+
dout("readpages %p file %p ctx %p nr_pages %d max %d\n",
458+
inode, file, rw_ctx, nr_pages, max);
455459
while (!list_empty(page_list)) {
456-
rc = start_read(inode, page_list, max);
460+
rc = start_read(inode, rw_ctx, page_list, max);
457461
if (rc < 0)
458462
goto out;
459463
}
@@ -574,7 +578,6 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
574578
struct ceph_fs_client *fsc;
575579
struct ceph_snap_context *snapc, *oldest;
576580
loff_t page_off = page_offset(page);
577-
long writeback_stat;
578581
int err, len = PAGE_SIZE;
579582
struct ceph_writeback_ctl ceph_wbc;
580583

@@ -615,8 +618,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
615618
dout("writepage %p page %p index %lu on %llu~%u snapc %p seq %lld\n",
616619
inode, page, page->index, page_off, len, snapc, snapc->seq);
617620

618-
writeback_stat = atomic_long_inc_return(&fsc->writeback_count);
619-
if (writeback_stat >
621+
if (atomic_long_inc_return(&fsc->writeback_count) >
620622
CONGESTION_ON_THRESH(fsc->mount_options->congestion_kb))
621623
set_bdi_congested(inode_to_bdi(inode), BLK_RW_ASYNC);
622624

@@ -651,6 +653,11 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
651653
end_page_writeback(page);
652654
ceph_put_wrbuffer_cap_refs(ci, 1, snapc);
653655
ceph_put_snap_context(snapc); /* page's reference */
656+
657+
if (atomic_long_dec_return(&fsc->writeback_count) <
658+
CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb))
659+
clear_bdi_congested(inode_to_bdi(inode), BLK_RW_ASYNC);
660+
654661
return err;
655662
}
656663

@@ -1450,9 +1457,10 @@ static int ceph_filemap_fault(struct vm_fault *vmf)
14501457

14511458
if ((got & (CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO)) ||
14521459
ci->i_inline_version == CEPH_INLINE_NONE) {
1453-
current->journal_info = vma->vm_file;
1460+
CEPH_DEFINE_RW_CONTEXT(rw_ctx, got);
1461+
ceph_add_rw_context(fi, &rw_ctx);
14541462
ret = filemap_fault(vmf);
1455-
current->journal_info = NULL;
1463+
ceph_del_rw_context(fi, &rw_ctx);
14561464
} else
14571465
ret = -EAGAIN;
14581466

0 commit comments

Comments
 (0)