@@ -760,12 +760,37 @@ static struct fuse_io_args *fuse_io_alloc(struct fuse_io_priv *io,
760
760
return ia ;
761
761
}
762
762
763
+ static struct fuse_io_args * fuse_io_folios_alloc (struct fuse_io_priv * io ,
764
+ unsigned int nfolios )
765
+ {
766
+ struct fuse_io_args * ia ;
767
+
768
+ ia = kzalloc (sizeof (* ia ), GFP_KERNEL );
769
+ if (ia ) {
770
+ ia -> io = io ;
771
+ ia -> ap .uses_folios = true;
772
+ ia -> ap .folios = fuse_folios_alloc (nfolios , GFP_KERNEL ,
773
+ & ia -> ap .folio_descs );
774
+ if (!ia -> ap .folios ) {
775
+ kfree (ia );
776
+ ia = NULL ;
777
+ }
778
+ }
779
+ return ia ;
780
+ }
781
+
763
782
static void fuse_io_free (struct fuse_io_args * ia )
764
783
{
765
784
kfree (ia -> ap .pages );
766
785
kfree (ia );
767
786
}
768
787
788
+ static void fuse_io_folios_free (struct fuse_io_args * ia )
789
+ {
790
+ kfree (ia -> ap .folios );
791
+ kfree (ia );
792
+ }
793
+
769
794
static void fuse_aio_complete_req (struct fuse_mount * fm , struct fuse_args * args ,
770
795
int err )
771
796
{
@@ -865,7 +890,7 @@ static void fuse_short_read(struct inode *inode, u64 attr_ver, size_t num_read,
865
890
* reached the client fs yet. So the hole is not present there.
866
891
*/
867
892
if (!fc -> writeback_cache ) {
868
- loff_t pos = page_offset (ap -> pages [0 ]) + num_read ;
893
+ loff_t pos = folio_pos (ap -> folios [0 ]) + num_read ;
869
894
fuse_read_update_size (inode , pos , attr_ver );
870
895
}
871
896
}
@@ -875,14 +900,14 @@ static int fuse_do_readfolio(struct file *file, struct folio *folio)
875
900
struct inode * inode = folio -> mapping -> host ;
876
901
struct fuse_mount * fm = get_fuse_mount (inode );
877
902
loff_t pos = folio_pos (folio );
878
- struct fuse_page_desc desc = { .length = PAGE_SIZE };
879
- struct page * page = & folio -> page ;
903
+ struct fuse_folio_desc desc = { .length = PAGE_SIZE };
880
904
struct fuse_io_args ia = {
881
905
.ap .args .page_zeroing = true,
882
906
.ap .args .out_pages = true,
883
- .ap .num_pages = 1 ,
884
- .ap .pages = & page ,
885
- .ap .descs = & desc ,
907
+ .ap .uses_folios = true,
908
+ .ap .num_folios = 1 ,
909
+ .ap .folios = & folio ,
910
+ .ap .folio_descs = & desc ,
886
911
};
887
912
ssize_t res ;
888
913
u64 attr_ver ;
@@ -941,8 +966,8 @@ static void fuse_readpages_end(struct fuse_mount *fm, struct fuse_args *args,
941
966
size_t num_read = args -> out_args [0 ].size ;
942
967
struct address_space * mapping = NULL ;
943
968
944
- for (i = 0 ; mapping == NULL && i < ap -> num_pages ; i ++ )
945
- mapping = ap -> pages [i ]-> mapping ;
969
+ for (i = 0 ; mapping == NULL && i < ap -> num_folios ; i ++ )
970
+ mapping = ap -> folios [i ]-> mapping ;
946
971
947
972
if (mapping ) {
948
973
struct inode * inode = mapping -> host ;
@@ -956,24 +981,22 @@ static void fuse_readpages_end(struct fuse_mount *fm, struct fuse_args *args,
956
981
fuse_invalidate_atime (inode );
957
982
}
958
983
959
- for (i = 0 ; i < ap -> num_pages ; i ++ ) {
960
- struct folio * folio = page_folio (ap -> pages [i ]);
961
-
962
- folio_end_read (folio , !err );
963
- }
984
+ for (i = 0 ; i < ap -> num_folios ; i ++ )
985
+ folio_end_read (ap -> folios [i ], !err );
964
986
if (ia -> ff )
965
987
fuse_file_put (ia -> ff , false);
966
988
967
- fuse_io_free (ia );
989
+ fuse_io_folios_free (ia );
968
990
}
969
991
970
992
static void fuse_send_readpages (struct fuse_io_args * ia , struct file * file )
971
993
{
972
994
struct fuse_file * ff = file -> private_data ;
973
995
struct fuse_mount * fm = ff -> fm ;
974
996
struct fuse_args_pages * ap = & ia -> ap ;
975
- loff_t pos = page_offset (ap -> pages [0 ]);
976
- size_t count = ap -> num_pages << PAGE_SHIFT ;
997
+ loff_t pos = folio_pos (ap -> folios [0 ]);
998
+ /* Currently, all folios in FUSE are one page */
999
+ size_t count = ap -> num_folios << PAGE_SHIFT ;
977
1000
ssize_t res ;
978
1001
int err ;
979
1002
@@ -984,7 +1007,7 @@ static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file)
984
1007
/* Don't overflow end offset */
985
1008
if (pos + (count - 1 ) == LLONG_MAX ) {
986
1009
count -- ;
987
- ap -> descs [ap -> num_pages - 1 ].length -- ;
1010
+ ap -> folio_descs [ap -> num_folios - 1 ].length -- ;
988
1011
}
989
1012
WARN_ON ((loff_t ) (pos + count ) < 0 );
990
1013
@@ -1045,16 +1068,16 @@ static void fuse_readahead(struct readahead_control *rac)
1045
1068
*/
1046
1069
break ;
1047
1070
1048
- ia = fuse_io_alloc (NULL , cur_pages );
1071
+ ia = fuse_io_folios_alloc (NULL , cur_pages );
1049
1072
if (!ia )
1050
1073
return ;
1051
1074
ap = & ia -> ap ;
1052
1075
1053
- while (ap -> num_pages < cur_pages ) {
1076
+ while (ap -> num_folios < cur_pages ) {
1054
1077
folio = readahead_folio (rac );
1055
- ap -> pages [ap -> num_pages ] = & folio -> page ;
1056
- ap -> descs [ap -> num_pages ].length = folio_size (folio );
1057
- ap -> num_pages ++ ;
1078
+ ap -> folios [ap -> num_folios ] = folio ;
1079
+ ap -> folio_descs [ap -> num_folios ].length = folio_size (folio );
1080
+ ap -> num_folios ++ ;
1058
1081
}
1059
1082
fuse_send_readpages (ia , rac -> file );
1060
1083
nr_pages -= cur_pages ;
0 commit comments