Skip to content

Commit 875fef4

Browse files
committed
Merge tag 'ceph-for-5.4-rc8' of git://github.com/ceph/ceph-client
Pull ceph fixes from Ilya Dryomov: "Two fixes for the buffered reads and O_DIRECT writes serialization patch that went into -rc1 and a fixup for a bogus warning on older gcc versions" * tag 'ceph-for-5.4-rc8' of git://github.com/ceph/ceph-client: rbd: silence bogus uninitialized warning in rbd_object_map_update_finish() ceph: increment/decrement dio counter on async requests ceph: take the inode lock before acquiring cap refs
2 parents a28f239 + 633739b commit 875fef4

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

drivers/block/rbd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@ static int rbd_object_map_update_finish(struct rbd_obj_request *obj_req,
20872087
struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev;
20882088
struct ceph_osd_data *osd_data;
20892089
u64 objno;
2090-
u8 state, new_state, current_state;
2090+
u8 state, new_state, uninitialized_var(current_state);
20912091
bool has_current_state;
20922092
void *p;
20932093

fs/ceph/file.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,9 @@ static void ceph_aio_complete(struct inode *inode,
753753
if (!atomic_dec_and_test(&aio_req->pending_reqs))
754754
return;
755755

756+
if (aio_req->iocb->ki_flags & IOCB_DIRECT)
757+
inode_dio_end(inode);
758+
756759
ret = aio_req->error;
757760
if (!ret)
758761
ret = aio_req->total_len;
@@ -1091,6 +1094,7 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter,
10911094
CEPH_CAP_FILE_RD);
10921095

10931096
list_splice(&aio_req->osd_reqs, &osd_reqs);
1097+
inode_dio_begin(inode);
10941098
while (!list_empty(&osd_reqs)) {
10951099
req = list_first_entry(&osd_reqs,
10961100
struct ceph_osd_request,
@@ -1264,14 +1268,24 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to)
12641268
dout("aio_read %p %llx.%llx %llu~%u trying to get caps on %p\n",
12651269
inode, ceph_vinop(inode), iocb->ki_pos, (unsigned)len, inode);
12661270

1271+
if (iocb->ki_flags & IOCB_DIRECT)
1272+
ceph_start_io_direct(inode);
1273+
else
1274+
ceph_start_io_read(inode);
1275+
12671276
if (fi->fmode & CEPH_FILE_MODE_LAZY)
12681277
want = CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO;
12691278
else
12701279
want = CEPH_CAP_FILE_CACHE;
12711280
ret = ceph_get_caps(filp, CEPH_CAP_FILE_RD, want, -1,
12721281
&got, &pinned_page);
1273-
if (ret < 0)
1282+
if (ret < 0) {
1283+
if (iocb->ki_flags & IOCB_DIRECT)
1284+
ceph_end_io_direct(inode);
1285+
else
1286+
ceph_end_io_read(inode);
12741287
return ret;
1288+
}
12751289

12761290
if ((got & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) == 0 ||
12771291
(iocb->ki_flags & IOCB_DIRECT) ||
@@ -1283,16 +1297,12 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to)
12831297

12841298
if (ci->i_inline_version == CEPH_INLINE_NONE) {
12851299
if (!retry_op && (iocb->ki_flags & IOCB_DIRECT)) {
1286-
ceph_start_io_direct(inode);
12871300
ret = ceph_direct_read_write(iocb, to,
12881301
NULL, NULL);
1289-
ceph_end_io_direct(inode);
12901302
if (ret >= 0 && ret < len)
12911303
retry_op = CHECK_EOF;
12921304
} else {
1293-
ceph_start_io_read(inode);
12941305
ret = ceph_sync_read(iocb, to, &retry_op);
1295-
ceph_end_io_read(inode);
12961306
}
12971307
} else {
12981308
retry_op = READ_INLINE;
@@ -1303,18 +1313,23 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to)
13031313
inode, ceph_vinop(inode), iocb->ki_pos, (unsigned)len,
13041314
ceph_cap_string(got));
13051315
ceph_add_rw_context(fi, &rw_ctx);
1306-
ceph_start_io_read(inode);
13071316
ret = generic_file_read_iter(iocb, to);
1308-
ceph_end_io_read(inode);
13091317
ceph_del_rw_context(fi, &rw_ctx);
13101318
}
1319+
13111320
dout("aio_read %p %llx.%llx dropping cap refs on %s = %d\n",
13121321
inode, ceph_vinop(inode), ceph_cap_string(got), (int)ret);
13131322
if (pinned_page) {
13141323
put_page(pinned_page);
13151324
pinned_page = NULL;
13161325
}
13171326
ceph_put_cap_refs(ci, got);
1327+
1328+
if (iocb->ki_flags & IOCB_DIRECT)
1329+
ceph_end_io_direct(inode);
1330+
else
1331+
ceph_end_io_read(inode);
1332+
13181333
if (retry_op > HAVE_RETRIED && ret >= 0) {
13191334
int statret;
13201335
struct page *page = NULL;

0 commit comments

Comments
 (0)