Skip to content

Commit e63046a

Browse files
committed
Merge tag 'vfs-6.15-rc1.ceph' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull vfs ceph updates from Christian Brauner: "This contains the work to remove access to page->index from ceph and fixes the test failure observed for ceph with generic/421 by refactoring ceph_writepages_start()" * tag 'vfs-6.15-rc1.ceph' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: fscrypt: Change fscrypt_encrypt_pagecache_blocks() to take a folio ceph: Fix error handling in fill_readdir_cache() fs: Remove page_mkwrite_check_truncate() ceph: Pass a folio to ceph_allocate_page_array() ceph: Convert ceph_move_dirty_page_in_page_array() to move_dirty_folio_in_page_array() ceph: Remove uses of page from ceph_process_folio_batch() ceph: Convert ceph_check_page_before_write() to use a folio ceph: Convert writepage_nounlock() to write_folio_nounlock() ceph: Convert ceph_readdir_cache_control to store a folio ceph: Convert ceph_find_incompatible() to take a folio ceph: Use a folio in ceph_page_mkwrite() ceph: Remove ceph_writepage() ceph: fix generic/421 test failure ceph: introduce ceph_submit_write() method ceph: introduce ceph_process_folio_batch() method ceph: extend ceph_writeback_ctl for ceph_writepages_start() refactoring
2 parents e41170c + 59b59a9 commit e63046a

File tree

12 files changed

+848
-541
lines changed

12 files changed

+848
-541
lines changed

fs/ceph/addr.c

Lines changed: 789 additions & 470 deletions
Large diffs are not rendered by default.

fs/ceph/dir.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,18 @@ __dcache_find_get_entry(struct dentry *parent, u64 idx,
141141
if (ptr_pos >= i_size_read(dir))
142142
return NULL;
143143

144-
if (!cache_ctl->page || ptr_pgoff != cache_ctl->page->index) {
144+
if (!cache_ctl->folio || ptr_pgoff != cache_ctl->folio->index) {
145145
ceph_readdir_cache_release(cache_ctl);
146-
cache_ctl->page = find_lock_page(&dir->i_data, ptr_pgoff);
147-
if (!cache_ctl->page) {
148-
doutc(cl, " page %lu not found\n", ptr_pgoff);
146+
cache_ctl->folio = filemap_lock_folio(&dir->i_data, ptr_pgoff);
147+
if (IS_ERR(cache_ctl->folio)) {
148+
cache_ctl->folio = NULL;
149+
doutc(cl, " folio %lu not found\n", ptr_pgoff);
149150
return ERR_PTR(-EAGAIN);
150151
}
151152
/* reading/filling the cache are serialized by
152-
i_rwsem, no need to use page lock */
153-
unlock_page(cache_ctl->page);
154-
cache_ctl->dentries = kmap(cache_ctl->page);
153+
i_rwsem, no need to use folio lock */
154+
folio_unlock(cache_ctl->folio);
155+
cache_ctl->dentries = kmap_local_folio(cache_ctl->folio, 0);
155156
}
156157

157158
cache_ctl->index = idx & idx_mask;

fs/ceph/inode.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,10 +1845,9 @@ static int readdir_prepopulate_inodes_only(struct ceph_mds_request *req,
18451845

18461846
void ceph_readdir_cache_release(struct ceph_readdir_cache_control *ctl)
18471847
{
1848-
if (ctl->page) {
1849-
kunmap(ctl->page);
1850-
put_page(ctl->page);
1851-
ctl->page = NULL;
1848+
if (ctl->folio) {
1849+
folio_release_kmap(ctl->folio, ctl->dentries);
1850+
ctl->folio = NULL;
18521851
}
18531852
}
18541853

@@ -1862,20 +1861,26 @@ static int fill_readdir_cache(struct inode *dir, struct dentry *dn,
18621861
unsigned idx = ctl->index % nsize;
18631862
pgoff_t pgoff = ctl->index / nsize;
18641863

1865-
if (!ctl->page || pgoff != ctl->page->index) {
1864+
if (!ctl->folio || pgoff != ctl->folio->index) {
18661865
ceph_readdir_cache_release(ctl);
1866+
fgf_t fgf = FGP_LOCK;
1867+
18671868
if (idx == 0)
1868-
ctl->page = grab_cache_page(&dir->i_data, pgoff);
1869-
else
1870-
ctl->page = find_lock_page(&dir->i_data, pgoff);
1871-
if (!ctl->page) {
1869+
fgf |= FGP_ACCESSED | FGP_CREAT;
1870+
1871+
ctl->folio = __filemap_get_folio(&dir->i_data, pgoff,
1872+
fgf, mapping_gfp_mask(&dir->i_data));
1873+
if (IS_ERR(ctl->folio)) {
1874+
int err = PTR_ERR(ctl->folio);
1875+
1876+
ctl->folio = NULL;
18721877
ctl->index = -1;
1873-
return idx == 0 ? -ENOMEM : 0;
1878+
return idx == 0 ? err : 0;
18741879
}
18751880
/* reading/filling the cache are serialized by
1876-
* i_rwsem, no need to use page lock */
1877-
unlock_page(ctl->page);
1878-
ctl->dentries = kmap(ctl->page);
1881+
* i_rwsem, no need to use folio lock */
1882+
folio_unlock(ctl->folio);
1883+
ctl->dentries = kmap_local_folio(ctl->folio, 0);
18791884
if (idx == 0)
18801885
memset(ctl->dentries, 0, PAGE_SIZE);
18811886
}

fs/ceph/mds_client.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5489,6 +5489,8 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
54895489
spin_lock_init(&mdsc->stopping_lock);
54905490
atomic_set(&mdsc->stopping_blockers, 0);
54915491
init_completion(&mdsc->stopping_waiter);
5492+
atomic64_set(&mdsc->dirty_folios, 0);
5493+
init_waitqueue_head(&mdsc->flush_end_wq);
54925494
init_waitqueue_head(&mdsc->session_close_wq);
54935495
INIT_LIST_HEAD(&mdsc->waiting_for_map);
54945496
mdsc->quotarealms_inodes = RB_ROOT;

fs/ceph/mds_client.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,9 @@ struct ceph_mds_client {
458458
atomic_t stopping_blockers;
459459
struct completion stopping_waiter;
460460

461+
atomic64_t dirty_folios;
462+
wait_queue_head_t flush_end_wq;
463+
461464
atomic64_t quotarealms_count; /* # realms with quota */
462465
/*
463466
* We keep a list of inodes we don't see in the mountpoint but that we

fs/ceph/super.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,17 @@ static void ceph_kill_sb(struct super_block *s)
15631563
*/
15641564
sync_filesystem(s);
15651565

1566+
if (atomic64_read(&mdsc->dirty_folios) > 0) {
1567+
wait_queue_head_t *wq = &mdsc->flush_end_wq;
1568+
long timeleft = wait_event_killable_timeout(*wq,
1569+
atomic64_read(&mdsc->dirty_folios) <= 0,
1570+
fsc->client->options->mount_timeout);
1571+
if (!timeleft) /* timed out */
1572+
pr_warn_client(cl, "umount timed out, %ld\n", timeleft);
1573+
else if (timeleft < 0) /* killed */
1574+
pr_warn_client(cl, "umount was killed, %ld\n", timeleft);
1575+
}
1576+
15661577
spin_lock(&mdsc->stopping_lock);
15671578
mdsc->stopping = CEPH_MDSC_STOPPING_FLUSHING;
15681579
wait = !!atomic_read(&mdsc->stopping_blockers);

fs/ceph/super.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ ceph_find_rw_context(struct ceph_file_info *cf)
903903
}
904904

905905
struct ceph_readdir_cache_control {
906-
struct page *page;
906+
struct folio *folio;
907907
struct dentry **dentries;
908908
int index;
909909
};

fs/crypto/crypto.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ int fscrypt_crypt_data_unit(const struct fscrypt_inode_info *ci,
153153
}
154154

155155
/**
156-
* fscrypt_encrypt_pagecache_blocks() - Encrypt data from a pagecache page
157-
* @page: the locked pagecache page containing the data to encrypt
156+
* fscrypt_encrypt_pagecache_blocks() - Encrypt data from a pagecache folio
157+
* @folio: the locked pagecache folio containing the data to encrypt
158158
* @len: size of the data to encrypt, in bytes
159159
* @offs: offset within @page of the data to encrypt, in bytes
160160
* @gfp_flags: memory allocation flags; see details below
@@ -177,23 +177,21 @@ int fscrypt_crypt_data_unit(const struct fscrypt_inode_info *ci,
177177
*
178178
* Return: the new encrypted bounce page on success; an ERR_PTR() on failure
179179
*/
180-
struct page *fscrypt_encrypt_pagecache_blocks(struct page *page,
181-
unsigned int len,
182-
unsigned int offs,
183-
gfp_t gfp_flags)
184-
180+
struct page *fscrypt_encrypt_pagecache_blocks(struct folio *folio,
181+
size_t len, size_t offs, gfp_t gfp_flags)
185182
{
186-
const struct inode *inode = page->mapping->host;
183+
const struct inode *inode = folio->mapping->host;
187184
const struct fscrypt_inode_info *ci = inode->i_crypt_info;
188185
const unsigned int du_bits = ci->ci_data_unit_bits;
189186
const unsigned int du_size = 1U << du_bits;
190187
struct page *ciphertext_page;
191-
u64 index = ((u64)page->index << (PAGE_SHIFT - du_bits)) +
188+
u64 index = ((u64)folio->index << (PAGE_SHIFT - du_bits)) +
192189
(offs >> du_bits);
193190
unsigned int i;
194191
int err;
195192

196-
if (WARN_ON_ONCE(!PageLocked(page)))
193+
VM_BUG_ON_FOLIO(folio_test_large(folio), folio);
194+
if (WARN_ON_ONCE(!folio_test_locked(folio)))
197195
return ERR_PTR(-EINVAL);
198196

199197
if (WARN_ON_ONCE(len <= 0 || !IS_ALIGNED(len | offs, du_size)))
@@ -205,15 +203,15 @@ struct page *fscrypt_encrypt_pagecache_blocks(struct page *page,
205203

206204
for (i = offs; i < offs + len; i += du_size, index++) {
207205
err = fscrypt_crypt_data_unit(ci, FS_ENCRYPT, index,
208-
page, ciphertext_page,
206+
&folio->page, ciphertext_page,
209207
du_size, i, gfp_flags);
210208
if (err) {
211209
fscrypt_free_bounce_page(ciphertext_page);
212210
return ERR_PTR(err);
213211
}
214212
}
215213
SetPagePrivate(ciphertext_page);
216-
set_page_private(ciphertext_page, (unsigned long)page);
214+
set_page_private(ciphertext_page, (unsigned long)folio);
217215
return ciphertext_page;
218216
}
219217
EXPORT_SYMBOL(fscrypt_encrypt_pagecache_blocks);

fs/ext4/page-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ int ext4_bio_write_folio(struct ext4_io_submit *io, struct folio *folio,
522522
if (io->io_bio)
523523
gfp_flags = GFP_NOWAIT | __GFP_NOWARN;
524524
retry_encrypt:
525-
bounce_page = fscrypt_encrypt_pagecache_blocks(&folio->page,
525+
bounce_page = fscrypt_encrypt_pagecache_blocks(folio,
526526
enc_bytes, 0, gfp_flags);
527527
if (IS_ERR(bounce_page)) {
528528
ret = PTR_ERR(bounce_page);

fs/f2fs/data.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2500,7 +2500,7 @@ int f2fs_encrypt_one_page(struct f2fs_io_info *fio)
25002500
return 0;
25012501

25022502
retry_encrypt:
2503-
fio->encrypted_page = fscrypt_encrypt_pagecache_blocks(page,
2503+
fio->encrypted_page = fscrypt_encrypt_pagecache_blocks(page_folio(page),
25042504
PAGE_SIZE, 0, gfp_flags);
25052505
if (IS_ERR(fio->encrypted_page)) {
25062506
/* flush pending IOs and wait for a while in the ENOMEM case */

0 commit comments

Comments
 (0)