Skip to content

Commit a55cf4f

Browse files
Matthew Wilcox (Oracle)brauner
authored andcommitted
ceph: Remove uses of page from ceph_process_folio_batch()
Remove uses of page->index and deprecated page APIs. Saves a lot of hidden calls to compound_head(). Also convert is_page_index_contiguous() to is_folio_index_contiguous() and make its arguments const. Signed-off-by: "Matthew Wilcox (Oracle)" <willy@infradead.org> Link: https://lore.kernel.org/r/20250217185119.430193-8-willy@infradead.org Tested-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 15fdaf2 commit a55cf4f

1 file changed

Lines changed: 22 additions & 25 deletions

File tree

fs/ceph/addr.c

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,10 +1216,10 @@ void ceph_allocate_page_array(struct address_space *mapping,
12161216
}
12171217

12181218
static inline
1219-
bool is_page_index_contiguous(struct ceph_writeback_ctl *ceph_wbc,
1220-
struct page *page)
1219+
bool is_folio_index_contiguous(const struct ceph_writeback_ctl *ceph_wbc,
1220+
const struct folio *folio)
12211221
{
1222-
return page->index == (ceph_wbc->offset + ceph_wbc->len) >> PAGE_SHIFT;
1222+
return folio->index == (ceph_wbc->offset + ceph_wbc->len) >> PAGE_SHIFT;
12231223
}
12241224

12251225
static inline
@@ -1284,7 +1284,6 @@ int ceph_process_folio_batch(struct address_space *mapping,
12841284
struct ceph_fs_client *fsc = ceph_inode_to_fs_client(inode);
12851285
struct ceph_client *cl = fsc->client;
12861286
struct folio *folio = NULL;
1287-
struct page *page = NULL;
12881287
unsigned i;
12891288
int rc = 0;
12901289

@@ -1294,11 +1293,9 @@ int ceph_process_folio_batch(struct address_space *mapping,
12941293
if (!folio)
12951294
continue;
12961295

1297-
page = &folio->page;
1298-
12991296
doutc(cl, "? %p idx %lu, folio_test_writeback %#x, "
13001297
"folio_test_dirty %#x, folio_test_locked %#x\n",
1301-
page, page->index, folio_test_writeback(folio),
1298+
folio, folio->index, folio_test_writeback(folio),
13021299
folio_test_dirty(folio),
13031300
folio_test_locked(folio));
13041301

@@ -1311,27 +1308,27 @@ int ceph_process_folio_batch(struct address_space *mapping,
13111308
}
13121309

13131310
if (ceph_wbc->locked_pages == 0)
1314-
lock_page(page); /* first page */
1315-
else if (!trylock_page(page))
1311+
folio_lock(folio);
1312+
else if (!folio_trylock(folio))
13161313
break;
13171314

13181315
rc = ceph_check_page_before_write(mapping, wbc,
13191316
ceph_wbc, folio);
13201317
if (rc == -ENODATA) {
13211318
rc = 0;
1322-
unlock_page(page);
1319+
folio_unlock(folio);
13231320
ceph_wbc->fbatch.folios[i] = NULL;
13241321
continue;
13251322
} else if (rc == -E2BIG) {
13261323
rc = 0;
1327-
unlock_page(page);
1324+
folio_unlock(folio);
13281325
ceph_wbc->fbatch.folios[i] = NULL;
13291326
break;
13301327
}
13311328

1332-
if (!clear_page_dirty_for_io(page)) {
1333-
doutc(cl, "%p !clear_page_dirty_for_io\n", page);
1334-
unlock_page(page);
1329+
if (!folio_clear_dirty_for_io(folio)) {
1330+
doutc(cl, "%p !folio_clear_dirty_for_io\n", folio);
1331+
folio_unlock(folio);
13351332
ceph_wbc->fbatch.folios[i] = NULL;
13361333
continue;
13371334
}
@@ -1343,35 +1340,35 @@ int ceph_process_folio_batch(struct address_space *mapping,
13431340
* allocate a page array
13441341
*/
13451342
if (ceph_wbc->locked_pages == 0) {
1346-
ceph_allocate_page_array(mapping, ceph_wbc, page);
1347-
} else if (!is_page_index_contiguous(ceph_wbc, page)) {
1343+
ceph_allocate_page_array(mapping, ceph_wbc, &folio->page);
1344+
} else if (!is_folio_index_contiguous(ceph_wbc, folio)) {
13481345
if (is_num_ops_too_big(ceph_wbc)) {
1349-
redirty_page_for_writepage(wbc, page);
1350-
unlock_page(page);
1346+
folio_redirty_for_writepage(wbc, folio);
1347+
folio_unlock(folio);
13511348
break;
13521349
}
13531350

13541351
ceph_wbc->num_ops++;
1355-
ceph_wbc->offset = (u64)page_offset(page);
1352+
ceph_wbc->offset = (u64)folio_pos(folio);
13561353
ceph_wbc->len = 0;
13571354
}
13581355

13591356
/* note position of first page in fbatch */
1360-
doutc(cl, "%llx.%llx will write page %p idx %lu\n",
1361-
ceph_vinop(inode), page, page->index);
1357+
doutc(cl, "%llx.%llx will write folio %p idx %lu\n",
1358+
ceph_vinop(inode), folio, folio->index);
13621359

13631360
fsc->write_congested = is_write_congestion_happened(fsc);
13641361

13651362
rc = ceph_move_dirty_page_in_page_array(mapping, wbc,
1366-
ceph_wbc, page);
1363+
ceph_wbc, &folio->page);
13671364
if (rc) {
1368-
redirty_page_for_writepage(wbc, page);
1369-
unlock_page(page);
1365+
folio_redirty_for_writepage(wbc, folio);
1366+
folio_unlock(folio);
13701367
break;
13711368
}
13721369

13731370
ceph_wbc->fbatch.folios[i] = NULL;
1374-
ceph_wbc->len += thp_size(page);
1371+
ceph_wbc->len += folio_size(folio);
13751372
}
13761373

13771374
ceph_wbc->processed_in_fbatch = i;

0 commit comments

Comments
 (0)