@@ -3822,13 +3822,13 @@ cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from)
38223822 return written ;
38233823}
38243824
3825- static struct cifs_readdata * cifs_readdata_alloc (work_func_t complete )
3825+ static struct cifs_io_subrequest * cifs_readdata_alloc (work_func_t complete )
38263826{
3827- struct cifs_readdata * rdata ;
3827+ struct cifs_io_subrequest * rdata ;
38283828
38293829 rdata = kzalloc (sizeof (* rdata ), GFP_KERNEL );
38303830 if (rdata ) {
3831- kref_init (& rdata -> refcount );
3831+ refcount_set (& rdata -> subreq . ref , 1 );
38323832 INIT_LIST_HEAD (& rdata -> list );
38333833 init_completion (& rdata -> done );
38343834 INIT_WORK (& rdata -> work , complete );
@@ -3838,11 +3838,8 @@ static struct cifs_readdata *cifs_readdata_alloc(work_func_t complete)
38383838}
38393839
38403840void
3841- cifs_readdata_release (struct kref * refcount )
3841+ cifs_readdata_release (struct cifs_io_subrequest * rdata )
38423842{
3843- struct cifs_readdata * rdata = container_of (refcount ,
3844- struct cifs_readdata , refcount );
3845-
38463843 if (rdata -> ctx )
38473844 kref_put (& rdata -> ctx -> refcount , cifs_aio_ctx_release );
38483845#ifdef CONFIG_CIFS_SMB_DIRECT
@@ -3862,16 +3859,16 @@ static void collect_uncached_read_data(struct cifs_aio_ctx *ctx);
38623859static void
38633860cifs_uncached_readv_complete (struct work_struct * work )
38643861{
3865- struct cifs_readdata * rdata = container_of ( work ,
3866- struct cifs_readdata , work );
3862+ struct cifs_io_subrequest * rdata =
3863+ container_of ( work , struct cifs_io_subrequest , work );
38673864
38683865 complete (& rdata -> done );
38693866 collect_uncached_read_data (rdata -> ctx );
38703867 /* the below call can possibly free the last ref to aio ctx */
3871- kref_put ( & rdata -> refcount , cifs_readdata_release );
3868+ cifs_put_readdata ( rdata );
38723869}
38733870
3874- static int cifs_resend_rdata (struct cifs_readdata * rdata ,
3871+ static int cifs_resend_rdata (struct cifs_io_subrequest * rdata ,
38753872 struct list_head * rdata_list ,
38763873 struct cifs_aio_ctx * ctx )
38773874{
@@ -3939,7 +3936,7 @@ static int cifs_resend_rdata(struct cifs_readdata *rdata,
39393936 } while (rc == - EAGAIN );
39403937
39413938fail :
3942- kref_put ( & rdata -> refcount , cifs_readdata_release );
3939+ cifs_put_readdata ( rdata );
39433940 return rc ;
39443941}
39453942
@@ -3948,7 +3945,7 @@ cifs_send_async_read(loff_t fpos, size_t len, struct cifsFileInfo *open_file,
39483945 struct cifs_sb_info * cifs_sb , struct list_head * rdata_list ,
39493946 struct cifs_aio_ctx * ctx )
39503947{
3951- struct cifs_readdata * rdata ;
3948+ struct cifs_io_subrequest * rdata ;
39523949 unsigned int rsize , nsegs , max_segs = INT_MAX ;
39533950 struct cifs_credits credits_on_stack ;
39543951 struct cifs_credits * credits = & credits_on_stack ;
@@ -4030,7 +4027,7 @@ cifs_send_async_read(loff_t fpos, size_t len, struct cifsFileInfo *open_file,
40304027
40314028 if (rc ) {
40324029 add_credits_and_wake_if (server , & rdata -> credits , 0 );
4033- kref_put ( & rdata -> refcount , cifs_readdata_release );
4030+ cifs_put_readdata ( rdata );
40344031 if (rc == - EAGAIN )
40354032 continue ;
40364033 break ;
@@ -4048,7 +4045,7 @@ cifs_send_async_read(loff_t fpos, size_t len, struct cifsFileInfo *open_file,
40484045static void
40494046collect_uncached_read_data (struct cifs_aio_ctx * ctx )
40504047{
4051- struct cifs_readdata * rdata , * tmp ;
4048+ struct cifs_io_subrequest * rdata , * tmp ;
40524049 struct cifs_sb_info * cifs_sb ;
40534050 int rc ;
40544051
@@ -4094,8 +4091,7 @@ collect_uncached_read_data(struct cifs_aio_ctx *ctx)
40944091 rdata -> cfile , cifs_sb ,
40954092 & tmp_list , ctx );
40964093
4097- kref_put (& rdata -> refcount ,
4098- cifs_readdata_release );
4094+ cifs_put_readdata (rdata );
40994095 }
41004096
41014097 list_splice (& tmp_list , & ctx -> list );
@@ -4111,7 +4107,7 @@ collect_uncached_read_data(struct cifs_aio_ctx *ctx)
41114107 ctx -> total_len += rdata -> got_bytes ;
41124108 }
41134109 list_del_init (& rdata -> list );
4114- kref_put ( & rdata -> refcount , cifs_readdata_release );
4110+ cifs_put_readdata ( rdata );
41154111 }
41164112
41174113 /* mask nodata case */
@@ -4483,8 +4479,8 @@ static void cifs_unlock_folios(struct address_space *mapping, pgoff_t first, pgo
44834479
44844480static void cifs_readahead_complete (struct work_struct * work )
44854481{
4486- struct cifs_readdata * rdata = container_of (work ,
4487- struct cifs_readdata , work );
4482+ struct cifs_io_subrequest * rdata = container_of (work ,
4483+ struct cifs_io_subrequest , work );
44884484 struct folio * folio ;
44894485 pgoff_t last ;
44904486 bool good = rdata -> result == 0 || (rdata -> result == - EAGAIN && rdata -> got_bytes );
@@ -4510,7 +4506,7 @@ static void cifs_readahead_complete(struct work_struct *work)
45104506 }
45114507 rcu_read_unlock ();
45124508
4513- kref_put ( & rdata -> refcount , cifs_readdata_release );
4509+ cifs_put_readdata ( rdata );
45144510}
45154511
45164512static void cifs_readahead (struct readahead_control * ractl )
@@ -4550,7 +4546,7 @@ static void cifs_readahead(struct readahead_control *ractl)
45504546 */
45514547 while ((nr_pages = ra_pages )) {
45524548 unsigned int i , rsize ;
4553- struct cifs_readdata * rdata ;
4549+ struct cifs_io_subrequest * rdata ;
45544550 struct cifs_credits credits_on_stack ;
45554551 struct cifs_credits * credits = & credits_on_stack ;
45564552 struct folio * folio ;
@@ -4669,11 +4665,11 @@ static void cifs_readahead(struct readahead_control *ractl)
46694665 rdata -> offset / PAGE_SIZE ,
46704666 (rdata -> offset + rdata -> bytes - 1 ) / PAGE_SIZE );
46714667 /* Fallback to the readpage in error/reconnect cases */
4672- kref_put ( & rdata -> refcount , cifs_readdata_release );
4668+ cifs_put_readdata ( rdata );
46734669 break ;
46744670 }
46754671
4676- kref_put ( & rdata -> refcount , cifs_readdata_release );
4672+ cifs_put_readdata ( rdata );
46774673 }
46784674
46794675 free_xid (xid );
0 commit comments