Skip to content

Commit c38a305

Browse files
konisgregkh
authored andcommitted
nilfs2: move page release outside of nilfs_delete_entry and nilfs_set_link
commit 584db20c181f5e28c0386d7987406ace7fbd3e49 upstream. Patch series "nilfs2: Folio conversions for directory paths". This series applies page->folio conversions to nilfs2 directory operations. This reduces hidden compound_head() calls and also converts deprecated kmap calls to kmap_local in the directory code. Although nilfs2 does not yet support large folios, Matthew has done his best here to include support for large folios, which will be needed for devices with large block sizes. This series corresponds to the second half of the original post [1], but with two complementary patches inserted at the beginning and some adjustments, to prevent a kmap_local constraint violation found during testing with highmem mapping. [1] https://lkml.kernel.org/r/[email protected] I have reviewed all changes and tested this for regular and small block sizes, both on machines with and without highmem mapping. No issues found. This patch (of 17): In a few directory operations, the call to nilfs_put_page() for a page obtained using nilfs_find_entry() or nilfs_dotdot() is hidden in nilfs_set_link() and nilfs_delete_entry(), making it difficult to track page release and preventing change of its call position. By moving nilfs_put_page() out of these functions, this makes the page get/put correspondence clearer and makes it easier to swap nilfs_put_page() calls (and kunmap calls within them) when modifying multiple directory entries simultaneously in nilfs_rename(). Also, update comments for nilfs_set_link() and nilfs_delete_entry() to reflect changes in their behavior. To make nilfs_put_page() visible from namei.c, this moves its definition to nilfs.h and replaces existing equivalents to use it, but the exposure of that definition is temporary and will be removed on a later kmap -> kmap_local conversion. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ryusuke Konishi <[email protected]> Reviewed-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Stable-dep-of: ee70999a988b ("nilfs2: handle errors that nilfs_prepare_chunk() may return") Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c07bfa4 commit c38a305

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

fs/nilfs2/dir.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ static inline unsigned int nilfs_chunk_size(struct inode *inode)
6464
return inode->i_sb->s_blocksize;
6565
}
6666

67-
static inline void nilfs_put_page(struct page *page)
68-
{
69-
kunmap(page);
70-
put_page(page);
71-
}
72-
7367
/*
7468
* Return the offset into page `page_nr' of the last valid
7569
* byte in that page, plus one.
@@ -450,7 +444,6 @@ int nilfs_inode_by_name(struct inode *dir, const struct qstr *qstr, ino_t *ino)
450444
return 0;
451445
}
452446

453-
/* Releases the page */
454447
void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de,
455448
struct page *page, struct inode *inode)
456449
{
@@ -465,7 +458,6 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de,
465458
de->inode = cpu_to_le64(inode->i_ino);
466459
nilfs_set_de_type(de, inode);
467460
nilfs_commit_chunk(page, mapping, from, to);
468-
nilfs_put_page(page);
469461
dir->i_mtime = dir->i_ctime = current_time(dir);
470462
}
471463

@@ -569,7 +561,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode)
569561

570562
/*
571563
* nilfs_delete_entry deletes a directory entry by merging it with the
572-
* previous entry. Page is up-to-date. Releases the page.
564+
* previous entry. Page is up-to-date.
573565
*/
574566
int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page)
575567
{
@@ -605,7 +597,6 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page)
605597
nilfs_commit_chunk(page, mapping, from, to);
606598
inode->i_ctime = inode->i_mtime = current_time(inode);
607599
out:
608-
nilfs_put_page(page);
609600
return err;
610601
}
611602

fs/nilfs2/namei.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ static int nilfs_do_unlink(struct inode *dir, struct dentry *dentry)
297297
set_nlink(inode, 1);
298298
}
299299
err = nilfs_delete_entry(de, page);
300+
nilfs_put_page(page);
300301
if (err)
301302
goto out;
302303

@@ -406,6 +407,7 @@ static int nilfs_rename(struct user_namespace *mnt_userns,
406407
goto out_dir;
407408
}
408409
nilfs_set_link(new_dir, new_de, new_page, old_inode);
410+
nilfs_put_page(new_page);
409411
nilfs_mark_inode_dirty(new_dir);
410412
new_inode->i_ctime = current_time(new_inode);
411413
if (dir_de)
@@ -429,9 +431,11 @@ static int nilfs_rename(struct user_namespace *mnt_userns,
429431
old_inode->i_ctime = current_time(old_inode);
430432

431433
nilfs_delete_entry(old_de, old_page);
434+
nilfs_put_page(old_page);
432435

433436
if (dir_de) {
434437
nilfs_set_link(old_inode, dir_de, dir_page, new_dir);
438+
nilfs_put_page(dir_page);
435439
drop_nlink(old_dir);
436440
}
437441
nilfs_mark_inode_dirty(old_dir);
@@ -441,13 +445,10 @@ static int nilfs_rename(struct user_namespace *mnt_userns,
441445
return err;
442446

443447
out_dir:
444-
if (dir_de) {
445-
kunmap(dir_page);
446-
put_page(dir_page);
447-
}
448+
if (dir_de)
449+
nilfs_put_page(dir_page);
448450
out_old:
449-
kunmap(old_page);
450-
put_page(old_page);
451+
nilfs_put_page(old_page);
451452
out:
452453
nilfs_transaction_abort(old_dir->i_sb);
453454
return err;

fs/nilfs2/nilfs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,12 @@ extern struct nilfs_dir_entry *nilfs_dotdot(struct inode *, struct page **);
243243
extern void nilfs_set_link(struct inode *, struct nilfs_dir_entry *,
244244
struct page *, struct inode *);
245245

246+
static inline void nilfs_put_page(struct page *page)
247+
{
248+
kunmap(page);
249+
put_page(page);
250+
}
251+
246252
/* file.c */
247253
extern int nilfs_sync_file(struct file *, loff_t, loff_t, int);
248254

0 commit comments

Comments
 (0)