@@ -1077,25 +1077,17 @@ static inline void iocb_destroy(struct aio_kiocb *iocb)
1077
1077
kmem_cache_free (kiocb_cachep , iocb );
1078
1078
}
1079
1079
1080
- static inline void iocb_put (struct aio_kiocb * iocb )
1081
- {
1082
- if (refcount_dec_and_test (& iocb -> ki_refcnt ))
1083
- iocb_destroy (iocb );
1084
- }
1085
-
1086
1080
/* aio_complete
1087
1081
* Called when the io request on the given iocb is complete.
1088
1082
*/
1089
- static void aio_complete (struct aio_kiocb * iocb , long res , long res2 )
1083
+ static void aio_complete (struct aio_kiocb * iocb )
1090
1084
{
1091
1085
struct kioctx * ctx = iocb -> ki_ctx ;
1092
1086
struct aio_ring * ring ;
1093
1087
struct io_event * ev_page , * event ;
1094
1088
unsigned tail , pos , head ;
1095
1089
unsigned long flags ;
1096
1090
1097
- iocb -> ki_res .res = res ;
1098
- iocb -> ki_res .res2 = res2 ;
1099
1091
/*
1100
1092
* Add a completion event to the ring buffer. Must be done holding
1101
1093
* ctx->completion_lock to prevent other code from messing with the tail
@@ -1161,7 +1153,14 @@ static void aio_complete(struct aio_kiocb *iocb, long res, long res2)
1161
1153
1162
1154
if (waitqueue_active (& ctx -> wait ))
1163
1155
wake_up (& ctx -> wait );
1164
- iocb_put (iocb );
1156
+ }
1157
+
1158
+ static inline void iocb_put (struct aio_kiocb * iocb )
1159
+ {
1160
+ if (refcount_dec_and_test (& iocb -> ki_refcnt )) {
1161
+ aio_complete (iocb );
1162
+ iocb_destroy (iocb );
1163
+ }
1165
1164
}
1166
1165
1167
1166
/* aio_read_events_ring
@@ -1435,7 +1434,9 @@ static void aio_complete_rw(struct kiocb *kiocb, long res, long res2)
1435
1434
file_end_write (kiocb -> ki_filp );
1436
1435
}
1437
1436
1438
- aio_complete (iocb , res , res2 );
1437
+ iocb -> ki_res .res = res ;
1438
+ iocb -> ki_res .res2 = res2 ;
1439
+ iocb_put (iocb );
1439
1440
}
1440
1441
1441
1442
static int aio_prep_rw (struct kiocb * req , const struct iocb * iocb )
@@ -1583,11 +1584,10 @@ static ssize_t aio_write(struct kiocb *req, const struct iocb *iocb,
1583
1584
1584
1585
static void aio_fsync_work (struct work_struct * work )
1585
1586
{
1586
- struct fsync_iocb * req = container_of (work , struct fsync_iocb , work );
1587
- int ret ;
1587
+ struct aio_kiocb * iocb = container_of (work , struct aio_kiocb , fsync .work );
1588
1588
1589
- ret = vfs_fsync (req -> file , req -> datasync );
1590
- aio_complete ( container_of ( req , struct aio_kiocb , fsync ), ret , 0 );
1589
+ iocb -> ki_res . res = vfs_fsync (iocb -> fsync . file , iocb -> fsync . datasync );
1590
+ iocb_put ( iocb );
1591
1591
}
1592
1592
1593
1593
static int aio_fsync (struct fsync_iocb * req , const struct iocb * iocb ,
@@ -1608,7 +1608,8 @@ static int aio_fsync(struct fsync_iocb *req, const struct iocb *iocb,
1608
1608
1609
1609
static inline void aio_poll_complete (struct aio_kiocb * iocb , __poll_t mask )
1610
1610
{
1611
- aio_complete (iocb , mangle_poll (mask ), 0 );
1611
+ iocb -> ki_res .res = mangle_poll (mask );
1612
+ iocb_put (iocb );
1612
1613
}
1613
1614
1614
1615
static void aio_poll_complete_work (struct work_struct * work )
0 commit comments