@@ -70,9 +70,9 @@ struct orangefs_writepages {
70
70
kuid_t uid ;
71
71
kgid_t gid ;
72
72
int maxpages ;
73
- int npages ;
73
+ int nfolios ;
74
74
struct address_space * mapping ;
75
- struct page * * pages ;
75
+ struct folio * * folios ;
76
76
struct bio_vec * bv ;
77
77
};
78
78
@@ -89,14 +89,14 @@ static int orangefs_writepages_work(struct orangefs_writepages *ow,
89
89
90
90
len = i_size_read (inode );
91
91
92
- start = offset_in_page ( ow -> off );
93
- for (i = 0 ; i < ow -> npages ; i ++ ) {
94
- set_page_writeback (ow -> pages [i ]);
95
- bvec_set_page (& ow -> bv [i ], ow -> pages [i ], PAGE_SIZE - start ,
96
- start );
92
+ start = offset_in_folio ( ow -> folios [ 0 ], ow -> off );
93
+ for (i = 0 ; i < ow -> nfolios ; i ++ ) {
94
+ folio_start_writeback (ow -> folios [i ]);
95
+ bvec_set_folio (& ow -> bv [i ], ow -> folios [i ],
96
+ folio_size ( ow -> folios [ i ]) - start , start );
97
97
start = 0 ;
98
98
}
99
- iov_iter_bvec (& iter , ITER_SOURCE , ow -> bv , ow -> npages , ow -> len );
99
+ iov_iter_bvec (& iter , ITER_SOURCE , ow -> bv , ow -> nfolios , ow -> len );
100
100
101
101
WARN_ON (ow -> off >= len );
102
102
if (ow -> off + ow -> len > len )
@@ -112,16 +112,11 @@ static int orangefs_writepages_work(struct orangefs_writepages *ow,
112
112
else
113
113
ret = 0 ;
114
114
115
- for (i = 0 ; i < ow -> npages ; i ++ ) {
116
- if (PagePrivate (ow -> pages [i ])) {
117
- wrp = (struct orangefs_write_range * )
118
- page_private (ow -> pages [i ]);
119
- ClearPagePrivate (ow -> pages [i ]);
120
- put_page (ow -> pages [i ]);
121
- kfree (wrp );
122
- }
123
- end_page_writeback (ow -> pages [i ]);
124
- unlock_page (ow -> pages [i ]);
115
+ for (i = 0 ; i < ow -> nfolios ; i ++ ) {
116
+ wrp = folio_detach_private (ow -> folios [i ]);
117
+ kfree (wrp );
118
+ folio_end_writeback (ow -> folios [i ]);
119
+ folio_unlock (ow -> folios [i ]);
125
120
}
126
121
127
122
return ret ;
@@ -142,41 +137,41 @@ static int orangefs_writepages_callback(struct folio *folio,
142
137
}
143
138
144
139
ret = -1 ;
145
- if (ow -> npages == 0 ) {
140
+ if (ow -> nfolios == 0 ) {
146
141
ow -> off = wr -> pos ;
147
142
ow -> len = wr -> len ;
148
143
ow -> uid = wr -> uid ;
149
144
ow -> gid = wr -> gid ;
150
- ow -> pages [ow -> npages ++ ] = & folio -> page ;
145
+ ow -> folios [ow -> nfolios ++ ] = folio ;
151
146
ret = 0 ;
152
147
goto done ;
153
148
}
154
149
if (!uid_eq (ow -> uid , wr -> uid ) || !gid_eq (ow -> gid , wr -> gid )) {
155
150
orangefs_writepages_work (ow , wbc );
156
- ow -> npages = 0 ;
151
+ ow -> nfolios = 0 ;
157
152
ret = -1 ;
158
153
goto done ;
159
154
}
160
155
if (ow -> off + ow -> len == wr -> pos ) {
161
156
ow -> len += wr -> len ;
162
- ow -> pages [ow -> npages ++ ] = & folio -> page ;
157
+ ow -> folios [ow -> nfolios ++ ] = folio ;
163
158
ret = 0 ;
164
159
goto done ;
165
160
}
166
161
done :
167
162
if (ret == -1 ) {
168
- if (ow -> npages ) {
163
+ if (ow -> nfolios ) {
169
164
orangefs_writepages_work (ow , wbc );
170
- ow -> npages = 0 ;
165
+ ow -> nfolios = 0 ;
171
166
}
172
167
ret = orangefs_writepage_locked (folio , wbc );
173
168
mapping_set_error (folio -> mapping , ret );
174
169
folio_unlock (folio );
175
170
folio_end_writeback (folio );
176
171
} else {
177
- if (ow -> npages == ow -> maxpages ) {
172
+ if (ow -> nfolios == ow -> maxpages ) {
178
173
orangefs_writepages_work (ow , wbc );
179
- ow -> npages = 0 ;
174
+ ow -> nfolios = 0 ;
180
175
}
181
176
}
182
177
return ret ;
@@ -194,25 +189,25 @@ static int orangefs_writepages(struct address_space *mapping,
194
189
if (!ow )
195
190
return - ENOMEM ;
196
191
ow -> maxpages = orangefs_bufmap_size_query ()/PAGE_SIZE ;
197
- ow -> pages = kcalloc (ow -> maxpages , sizeof (struct page * ), GFP_KERNEL );
198
- if (!ow -> pages ) {
192
+ ow -> folios = kcalloc (ow -> maxpages , sizeof (struct folio * ), GFP_KERNEL );
193
+ if (!ow -> folios ) {
199
194
kfree (ow );
200
195
return - ENOMEM ;
201
196
}
202
197
ow -> bv = kcalloc (ow -> maxpages , sizeof (struct bio_vec ), GFP_KERNEL );
203
198
if (!ow -> bv ) {
204
- kfree (ow -> pages );
199
+ kfree (ow -> folios );
205
200
kfree (ow );
206
201
return - ENOMEM ;
207
202
}
208
203
ow -> mapping = mapping ;
209
204
blk_start_plug (& plug );
210
205
while ((folio = writeback_iter (mapping , wbc , folio , & error )))
211
206
error = orangefs_writepages_callback (folio , wbc , ow );
212
- if (ow -> npages )
207
+ if (ow -> nfolios )
213
208
error = orangefs_writepages_work (ow , wbc );
214
209
blk_finish_plug (& plug );
215
- kfree (ow -> pages );
210
+ kfree (ow -> folios );
216
211
kfree (ow -> bv );
217
212
kfree (ow );
218
213
return error ;
0 commit comments