@@ -753,6 +753,9 @@ static void ceph_aio_complete(struct inode *inode,
753
753
if (!atomic_dec_and_test (& aio_req -> pending_reqs ))
754
754
return ;
755
755
756
+ if (aio_req -> iocb -> ki_flags & IOCB_DIRECT )
757
+ inode_dio_end (inode );
758
+
756
759
ret = aio_req -> error ;
757
760
if (!ret )
758
761
ret = aio_req -> total_len ;
@@ -1091,6 +1094,7 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter,
1091
1094
CEPH_CAP_FILE_RD );
1092
1095
1093
1096
list_splice (& aio_req -> osd_reqs , & osd_reqs );
1097
+ inode_dio_begin (inode );
1094
1098
while (!list_empty (& osd_reqs )) {
1095
1099
req = list_first_entry (& osd_reqs ,
1096
1100
struct ceph_osd_request ,
@@ -1264,14 +1268,24 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to)
1264
1268
dout ("aio_read %p %llx.%llx %llu~%u trying to get caps on %p\n" ,
1265
1269
inode , ceph_vinop (inode ), iocb -> ki_pos , (unsigned )len , inode );
1266
1270
1271
+ if (iocb -> ki_flags & IOCB_DIRECT )
1272
+ ceph_start_io_direct (inode );
1273
+ else
1274
+ ceph_start_io_read (inode );
1275
+
1267
1276
if (fi -> fmode & CEPH_FILE_MODE_LAZY )
1268
1277
want = CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO ;
1269
1278
else
1270
1279
want = CEPH_CAP_FILE_CACHE ;
1271
1280
ret = ceph_get_caps (filp , CEPH_CAP_FILE_RD , want , -1 ,
1272
1281
& 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 );
1274
1287
return ret ;
1288
+ }
1275
1289
1276
1290
if ((got & (CEPH_CAP_FILE_CACHE |CEPH_CAP_FILE_LAZYIO )) == 0 ||
1277
1291
(iocb -> ki_flags & IOCB_DIRECT ) ||
@@ -1283,16 +1297,12 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to)
1283
1297
1284
1298
if (ci -> i_inline_version == CEPH_INLINE_NONE ) {
1285
1299
if (!retry_op && (iocb -> ki_flags & IOCB_DIRECT )) {
1286
- ceph_start_io_direct (inode );
1287
1300
ret = ceph_direct_read_write (iocb , to ,
1288
1301
NULL , NULL );
1289
- ceph_end_io_direct (inode );
1290
1302
if (ret >= 0 && ret < len )
1291
1303
retry_op = CHECK_EOF ;
1292
1304
} else {
1293
- ceph_start_io_read (inode );
1294
1305
ret = ceph_sync_read (iocb , to , & retry_op );
1295
- ceph_end_io_read (inode );
1296
1306
}
1297
1307
} else {
1298
1308
retry_op = READ_INLINE ;
@@ -1303,18 +1313,23 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to)
1303
1313
inode , ceph_vinop (inode ), iocb -> ki_pos , (unsigned )len ,
1304
1314
ceph_cap_string (got ));
1305
1315
ceph_add_rw_context (fi , & rw_ctx );
1306
- ceph_start_io_read (inode );
1307
1316
ret = generic_file_read_iter (iocb , to );
1308
- ceph_end_io_read (inode );
1309
1317
ceph_del_rw_context (fi , & rw_ctx );
1310
1318
}
1319
+
1311
1320
dout ("aio_read %p %llx.%llx dropping cap refs on %s = %d\n" ,
1312
1321
inode , ceph_vinop (inode ), ceph_cap_string (got ), (int )ret );
1313
1322
if (pinned_page ) {
1314
1323
put_page (pinned_page );
1315
1324
pinned_page = NULL ;
1316
1325
}
1317
1326
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
+
1318
1333
if (retry_op > HAVE_RETRIED && ret >= 0 ) {
1319
1334
int statret ;
1320
1335
struct page * page = NULL ;
0 commit comments