Re: [PATCH] f2fs: don't put dentry page in pagecache into highmem
OK, got it. On 2018/3/19 14:23, Jaegeuk Kim wrote: On 03/19, Yunlong Song wrote: Hi, Jaegeuk, I find this patch is removed from current branch of dev-test recently, why? Any bugs? Moved into the beginning of the tree for cherry-picking into f2fs-stable. Thanks, On 2018/2/28 20:31, Yunlong Song wrote: Previous dentry page uses highmem, which will cause panic in platforms using highmem (such as arm), since the address space of dentry pages from highmem directly goes into the decryption path via the function fscrypt_fname_disk_to_usr. But sg_init_one assumes the address is not from highmem, and then cause panic since it doesn't call kmap_high but kunmap_high is triggered at the end. To fix this problem in a simple way, this patch avoids to put dentry page in pagecache into highmem. Signed-off-by: Yunlong Song--- fs/f2fs/dir.c | 23 +-- fs/f2fs/f2fs.h | 6 -- fs/f2fs/inline.c| 3 +-- fs/f2fs/inode.c | 2 +- fs/f2fs/namei.c | 14 +- fs/f2fs/recovery.c | 11 +-- include/linux/f2fs_fs.h | 1 - 7 files changed, 13 insertions(+), 47 deletions(-) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index f00b5ed..797eb05 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -94,14 +94,12 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, struct f2fs_dir_entry *de; struct f2fs_dentry_ptr d; - dentry_blk = (struct f2fs_dentry_block *)kmap(dentry_page); + dentry_blk = (struct f2fs_dentry_block *)page_address(dentry_page); make_dentry_ptr_block(NULL, , dentry_blk); de = find_target_dentry(fname, namehash, max_slots, ); if (de) *res_page = dentry_page; - else - kunmap(dentry_page); return de; } @@ -287,7 +285,6 @@ ino_t f2fs_inode_by_name(struct inode *dir, const struct qstr *qstr, de = f2fs_find_entry(dir, qstr, page); if (de) { res = le32_to_cpu(de->ino); - f2fs_dentry_kunmap(dir, *page); f2fs_put_page(*page, 0); } @@ -302,7 +299,6 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de, f2fs_wait_on_page_writeback(page, type, true); de->ino = cpu_to_le32(inode->i_ino); set_de_type(de, inode->i_mode); - f2fs_dentry_kunmap(dir, page); set_page_dirty(page); dir->i_mtime = dir->i_ctime = current_time(dir); @@ -350,13 +346,11 @@ static int make_empty_dir(struct inode *inode, if (IS_ERR(dentry_page)) return PTR_ERR(dentry_page); - dentry_blk = kmap_atomic(dentry_page); + dentry_blk = page_address(dentry_page); make_dentry_ptr_block(NULL, , dentry_blk); do_make_empty_dir(inode, parent, ); - kunmap_atomic(dentry_blk); - set_page_dirty(dentry_page); f2fs_put_page(dentry_page, 1); return 0; @@ -547,13 +541,12 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name, if (IS_ERR(dentry_page)) return PTR_ERR(dentry_page); - dentry_blk = kmap(dentry_page); + dentry_blk = page_address(dentry_page); bit_pos = room_for_filename(_blk->dentry_bitmap, slots, NR_DENTRY_IN_BLOCK); if (bit_pos < NR_DENTRY_IN_BLOCK) goto add_dentry; - kunmap(dentry_page); f2fs_put_page(dentry_page, 1); } @@ -588,7 +581,6 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name, if (inode) up_write(_I(inode)->i_sem); - kunmap(dentry_page); f2fs_put_page(dentry_page, 1); return err; @@ -642,7 +634,6 @@ int __f2fs_add_link(struct inode *dir, const struct qstr *name, F2FS_I(dir)->task = NULL; } if (de) { - f2fs_dentry_kunmap(dir, page); f2fs_put_page(page, 0); err = -EEXIST; } else if (IS_ERR(page)) { @@ -730,7 +721,6 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page, bit_pos = find_next_bit_le(_blk->dentry_bitmap, NR_DENTRY_IN_BLOCK, 0); - kunmap(page); /* kunmap - pair of f2fs_find_entry */ set_page_dirty(page); dir->i_ctime = dir->i_mtime = current_time(dir); @@ -775,7 +765,7 @@ bool f2fs_empty_dir(struct inode *dir) return false; } - dentry_blk = kmap_atomic(dentry_page); + dentry_blk = page_address(dentry_page); if (bidx == 0) bit_pos = 2; else @@ -783,7 +773,6 @@ bool f2fs_empty_dir(struct inode *dir) bit_pos = find_next_bit_le(_blk->dentry_bitmap,
Re: [PATCH] f2fs: don't put dentry page in pagecache into highmem
OK, got it. On 2018/3/19 14:23, Jaegeuk Kim wrote: On 03/19, Yunlong Song wrote: Hi, Jaegeuk, I find this patch is removed from current branch of dev-test recently, why? Any bugs? Moved into the beginning of the tree for cherry-picking into f2fs-stable. Thanks, On 2018/2/28 20:31, Yunlong Song wrote: Previous dentry page uses highmem, which will cause panic in platforms using highmem (such as arm), since the address space of dentry pages from highmem directly goes into the decryption path via the function fscrypt_fname_disk_to_usr. But sg_init_one assumes the address is not from highmem, and then cause panic since it doesn't call kmap_high but kunmap_high is triggered at the end. To fix this problem in a simple way, this patch avoids to put dentry page in pagecache into highmem. Signed-off-by: Yunlong Song --- fs/f2fs/dir.c | 23 +-- fs/f2fs/f2fs.h | 6 -- fs/f2fs/inline.c| 3 +-- fs/f2fs/inode.c | 2 +- fs/f2fs/namei.c | 14 +- fs/f2fs/recovery.c | 11 +-- include/linux/f2fs_fs.h | 1 - 7 files changed, 13 insertions(+), 47 deletions(-) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index f00b5ed..797eb05 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -94,14 +94,12 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, struct f2fs_dir_entry *de; struct f2fs_dentry_ptr d; - dentry_blk = (struct f2fs_dentry_block *)kmap(dentry_page); + dentry_blk = (struct f2fs_dentry_block *)page_address(dentry_page); make_dentry_ptr_block(NULL, , dentry_blk); de = find_target_dentry(fname, namehash, max_slots, ); if (de) *res_page = dentry_page; - else - kunmap(dentry_page); return de; } @@ -287,7 +285,6 @@ ino_t f2fs_inode_by_name(struct inode *dir, const struct qstr *qstr, de = f2fs_find_entry(dir, qstr, page); if (de) { res = le32_to_cpu(de->ino); - f2fs_dentry_kunmap(dir, *page); f2fs_put_page(*page, 0); } @@ -302,7 +299,6 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de, f2fs_wait_on_page_writeback(page, type, true); de->ino = cpu_to_le32(inode->i_ino); set_de_type(de, inode->i_mode); - f2fs_dentry_kunmap(dir, page); set_page_dirty(page); dir->i_mtime = dir->i_ctime = current_time(dir); @@ -350,13 +346,11 @@ static int make_empty_dir(struct inode *inode, if (IS_ERR(dentry_page)) return PTR_ERR(dentry_page); - dentry_blk = kmap_atomic(dentry_page); + dentry_blk = page_address(dentry_page); make_dentry_ptr_block(NULL, , dentry_blk); do_make_empty_dir(inode, parent, ); - kunmap_atomic(dentry_blk); - set_page_dirty(dentry_page); f2fs_put_page(dentry_page, 1); return 0; @@ -547,13 +541,12 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name, if (IS_ERR(dentry_page)) return PTR_ERR(dentry_page); - dentry_blk = kmap(dentry_page); + dentry_blk = page_address(dentry_page); bit_pos = room_for_filename(_blk->dentry_bitmap, slots, NR_DENTRY_IN_BLOCK); if (bit_pos < NR_DENTRY_IN_BLOCK) goto add_dentry; - kunmap(dentry_page); f2fs_put_page(dentry_page, 1); } @@ -588,7 +581,6 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name, if (inode) up_write(_I(inode)->i_sem); - kunmap(dentry_page); f2fs_put_page(dentry_page, 1); return err; @@ -642,7 +634,6 @@ int __f2fs_add_link(struct inode *dir, const struct qstr *name, F2FS_I(dir)->task = NULL; } if (de) { - f2fs_dentry_kunmap(dir, page); f2fs_put_page(page, 0); err = -EEXIST; } else if (IS_ERR(page)) { @@ -730,7 +721,6 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page, bit_pos = find_next_bit_le(_blk->dentry_bitmap, NR_DENTRY_IN_BLOCK, 0); - kunmap(page); /* kunmap - pair of f2fs_find_entry */ set_page_dirty(page); dir->i_ctime = dir->i_mtime = current_time(dir); @@ -775,7 +765,7 @@ bool f2fs_empty_dir(struct inode *dir) return false; } - dentry_blk = kmap_atomic(dentry_page); + dentry_blk = page_address(dentry_page); if (bidx == 0) bit_pos = 2; else @@ -783,7 +773,6 @@ bool f2fs_empty_dir(struct inode *dir) bit_pos = find_next_bit_le(_blk->dentry_bitmap,
Re: [PATCH] f2fs: don't put dentry page in pagecache into highmem
On 03/19, Yunlong Song wrote: > Hi, Jaegeuk, > I find this patch is removed from current branch of dev-test > recently, why? Any bugs? Moved into the beginning of the tree for cherry-picking into f2fs-stable. Thanks, > > On 2018/2/28 20:31, Yunlong Song wrote: > > Previous dentry page uses highmem, which will cause panic in platforms > > using highmem (such as arm), since the address space of dentry pages > > from highmem directly goes into the decryption path via the function > > fscrypt_fname_disk_to_usr. But sg_init_one assumes the address is not > > from highmem, and then cause panic since it doesn't call kmap_high but > > kunmap_high is triggered at the end. To fix this problem in a simple > > way, this patch avoids to put dentry page in pagecache into highmem. > > > > Signed-off-by: Yunlong Song> > --- > > fs/f2fs/dir.c | 23 +-- > > fs/f2fs/f2fs.h | 6 -- > > fs/f2fs/inline.c| 3 +-- > > fs/f2fs/inode.c | 2 +- > > fs/f2fs/namei.c | 14 +- > > fs/f2fs/recovery.c | 11 +-- > > include/linux/f2fs_fs.h | 1 - > > 7 files changed, 13 insertions(+), 47 deletions(-) > > > > diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c > > index f00b5ed..797eb05 100644 > > --- a/fs/f2fs/dir.c > > +++ b/fs/f2fs/dir.c > > @@ -94,14 +94,12 @@ static struct f2fs_dir_entry *find_in_block(struct page > > *dentry_page, > > struct f2fs_dir_entry *de; > > struct f2fs_dentry_ptr d; > > - dentry_blk = (struct f2fs_dentry_block *)kmap(dentry_page); > > + dentry_blk = (struct f2fs_dentry_block *)page_address(dentry_page); > > make_dentry_ptr_block(NULL, , dentry_blk); > > de = find_target_dentry(fname, namehash, max_slots, ); > > if (de) > > *res_page = dentry_page; > > - else > > - kunmap(dentry_page); > > return de; > > } > > @@ -287,7 +285,6 @@ ino_t f2fs_inode_by_name(struct inode *dir, const > > struct qstr *qstr, > > de = f2fs_find_entry(dir, qstr, page); > > if (de) { > > res = le32_to_cpu(de->ino); > > - f2fs_dentry_kunmap(dir, *page); > > f2fs_put_page(*page, 0); > > } > > @@ -302,7 +299,6 @@ void f2fs_set_link(struct inode *dir, struct > > f2fs_dir_entry *de, > > f2fs_wait_on_page_writeback(page, type, true); > > de->ino = cpu_to_le32(inode->i_ino); > > set_de_type(de, inode->i_mode); > > - f2fs_dentry_kunmap(dir, page); > > set_page_dirty(page); > > dir->i_mtime = dir->i_ctime = current_time(dir); > > @@ -350,13 +346,11 @@ static int make_empty_dir(struct inode *inode, > > if (IS_ERR(dentry_page)) > > return PTR_ERR(dentry_page); > > - dentry_blk = kmap_atomic(dentry_page); > > + dentry_blk = page_address(dentry_page); > > make_dentry_ptr_block(NULL, , dentry_blk); > > do_make_empty_dir(inode, parent, ); > > - kunmap_atomic(dentry_blk); > > - > > set_page_dirty(dentry_page); > > f2fs_put_page(dentry_page, 1); > > return 0; > > @@ -547,13 +541,12 @@ int f2fs_add_regular_entry(struct inode *dir, const > > struct qstr *new_name, > > if (IS_ERR(dentry_page)) > > return PTR_ERR(dentry_page); > > - dentry_blk = kmap(dentry_page); > > + dentry_blk = page_address(dentry_page); > > bit_pos = room_for_filename(_blk->dentry_bitmap, > > slots, NR_DENTRY_IN_BLOCK); > > if (bit_pos < NR_DENTRY_IN_BLOCK) > > goto add_dentry; > > - kunmap(dentry_page); > > f2fs_put_page(dentry_page, 1); > > } > > @@ -588,7 +581,6 @@ int f2fs_add_regular_entry(struct inode *dir, const > > struct qstr *new_name, > > if (inode) > > up_write(_I(inode)->i_sem); > > - kunmap(dentry_page); > > f2fs_put_page(dentry_page, 1); > > return err; > > @@ -642,7 +634,6 @@ int __f2fs_add_link(struct inode *dir, const struct > > qstr *name, > > F2FS_I(dir)->task = NULL; > > } > > if (de) { > > - f2fs_dentry_kunmap(dir, page); > > f2fs_put_page(page, 0); > > err = -EEXIST; > > } else if (IS_ERR(page)) { > > @@ -730,7 +721,6 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, > > struct page *page, > > bit_pos = find_next_bit_le(_blk->dentry_bitmap, > > NR_DENTRY_IN_BLOCK, > > 0); > > - kunmap(page); /* kunmap - pair of f2fs_find_entry */ > > set_page_dirty(page); > > dir->i_ctime = dir->i_mtime = current_time(dir); > > @@ -775,7 +765,7 @@ bool f2fs_empty_dir(struct inode *dir) > > return false; > > } > > - dentry_blk = kmap_atomic(dentry_page); > > + dentry_blk = page_address(dentry_page); > > if (bidx == 0) > > bit_pos = 2; > > else > > @@ -783,7 +773,6 @@ bool
Re: [PATCH] f2fs: don't put dentry page in pagecache into highmem
On 03/19, Yunlong Song wrote: > Hi, Jaegeuk, > I find this patch is removed from current branch of dev-test > recently, why? Any bugs? Moved into the beginning of the tree for cherry-picking into f2fs-stable. Thanks, > > On 2018/2/28 20:31, Yunlong Song wrote: > > Previous dentry page uses highmem, which will cause panic in platforms > > using highmem (such as arm), since the address space of dentry pages > > from highmem directly goes into the decryption path via the function > > fscrypt_fname_disk_to_usr. But sg_init_one assumes the address is not > > from highmem, and then cause panic since it doesn't call kmap_high but > > kunmap_high is triggered at the end. To fix this problem in a simple > > way, this patch avoids to put dentry page in pagecache into highmem. > > > > Signed-off-by: Yunlong Song > > --- > > fs/f2fs/dir.c | 23 +-- > > fs/f2fs/f2fs.h | 6 -- > > fs/f2fs/inline.c| 3 +-- > > fs/f2fs/inode.c | 2 +- > > fs/f2fs/namei.c | 14 +- > > fs/f2fs/recovery.c | 11 +-- > > include/linux/f2fs_fs.h | 1 - > > 7 files changed, 13 insertions(+), 47 deletions(-) > > > > diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c > > index f00b5ed..797eb05 100644 > > --- a/fs/f2fs/dir.c > > +++ b/fs/f2fs/dir.c > > @@ -94,14 +94,12 @@ static struct f2fs_dir_entry *find_in_block(struct page > > *dentry_page, > > struct f2fs_dir_entry *de; > > struct f2fs_dentry_ptr d; > > - dentry_blk = (struct f2fs_dentry_block *)kmap(dentry_page); > > + dentry_blk = (struct f2fs_dentry_block *)page_address(dentry_page); > > make_dentry_ptr_block(NULL, , dentry_blk); > > de = find_target_dentry(fname, namehash, max_slots, ); > > if (de) > > *res_page = dentry_page; > > - else > > - kunmap(dentry_page); > > return de; > > } > > @@ -287,7 +285,6 @@ ino_t f2fs_inode_by_name(struct inode *dir, const > > struct qstr *qstr, > > de = f2fs_find_entry(dir, qstr, page); > > if (de) { > > res = le32_to_cpu(de->ino); > > - f2fs_dentry_kunmap(dir, *page); > > f2fs_put_page(*page, 0); > > } > > @@ -302,7 +299,6 @@ void f2fs_set_link(struct inode *dir, struct > > f2fs_dir_entry *de, > > f2fs_wait_on_page_writeback(page, type, true); > > de->ino = cpu_to_le32(inode->i_ino); > > set_de_type(de, inode->i_mode); > > - f2fs_dentry_kunmap(dir, page); > > set_page_dirty(page); > > dir->i_mtime = dir->i_ctime = current_time(dir); > > @@ -350,13 +346,11 @@ static int make_empty_dir(struct inode *inode, > > if (IS_ERR(dentry_page)) > > return PTR_ERR(dentry_page); > > - dentry_blk = kmap_atomic(dentry_page); > > + dentry_blk = page_address(dentry_page); > > make_dentry_ptr_block(NULL, , dentry_blk); > > do_make_empty_dir(inode, parent, ); > > - kunmap_atomic(dentry_blk); > > - > > set_page_dirty(dentry_page); > > f2fs_put_page(dentry_page, 1); > > return 0; > > @@ -547,13 +541,12 @@ int f2fs_add_regular_entry(struct inode *dir, const > > struct qstr *new_name, > > if (IS_ERR(dentry_page)) > > return PTR_ERR(dentry_page); > > - dentry_blk = kmap(dentry_page); > > + dentry_blk = page_address(dentry_page); > > bit_pos = room_for_filename(_blk->dentry_bitmap, > > slots, NR_DENTRY_IN_BLOCK); > > if (bit_pos < NR_DENTRY_IN_BLOCK) > > goto add_dentry; > > - kunmap(dentry_page); > > f2fs_put_page(dentry_page, 1); > > } > > @@ -588,7 +581,6 @@ int f2fs_add_regular_entry(struct inode *dir, const > > struct qstr *new_name, > > if (inode) > > up_write(_I(inode)->i_sem); > > - kunmap(dentry_page); > > f2fs_put_page(dentry_page, 1); > > return err; > > @@ -642,7 +634,6 @@ int __f2fs_add_link(struct inode *dir, const struct > > qstr *name, > > F2FS_I(dir)->task = NULL; > > } > > if (de) { > > - f2fs_dentry_kunmap(dir, page); > > f2fs_put_page(page, 0); > > err = -EEXIST; > > } else if (IS_ERR(page)) { > > @@ -730,7 +721,6 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, > > struct page *page, > > bit_pos = find_next_bit_le(_blk->dentry_bitmap, > > NR_DENTRY_IN_BLOCK, > > 0); > > - kunmap(page); /* kunmap - pair of f2fs_find_entry */ > > set_page_dirty(page); > > dir->i_ctime = dir->i_mtime = current_time(dir); > > @@ -775,7 +765,7 @@ bool f2fs_empty_dir(struct inode *dir) > > return false; > > } > > - dentry_blk = kmap_atomic(dentry_page); > > + dentry_blk = page_address(dentry_page); > > if (bidx == 0) > > bit_pos = 2; > > else > > @@ -783,7 +773,6 @@ bool f2fs_empty_dir(struct inode
Re: [PATCH] f2fs: don't put dentry page in pagecache into highmem
Hi, Jaegeuk, I find this patch is removed from current branch of dev-test recently, why? Any bugs? On 2018/2/28 20:31, Yunlong Song wrote: Previous dentry page uses highmem, which will cause panic in platforms using highmem (such as arm), since the address space of dentry pages from highmem directly goes into the decryption path via the function fscrypt_fname_disk_to_usr. But sg_init_one assumes the address is not from highmem, and then cause panic since it doesn't call kmap_high but kunmap_high is triggered at the end. To fix this problem in a simple way, this patch avoids to put dentry page in pagecache into highmem. Signed-off-by: Yunlong Song--- fs/f2fs/dir.c | 23 +-- fs/f2fs/f2fs.h | 6 -- fs/f2fs/inline.c| 3 +-- fs/f2fs/inode.c | 2 +- fs/f2fs/namei.c | 14 +- fs/f2fs/recovery.c | 11 +-- include/linux/f2fs_fs.h | 1 - 7 files changed, 13 insertions(+), 47 deletions(-) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index f00b5ed..797eb05 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -94,14 +94,12 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, struct f2fs_dir_entry *de; struct f2fs_dentry_ptr d; - dentry_blk = (struct f2fs_dentry_block *)kmap(dentry_page); + dentry_blk = (struct f2fs_dentry_block *)page_address(dentry_page); make_dentry_ptr_block(NULL, , dentry_blk); de = find_target_dentry(fname, namehash, max_slots, ); if (de) *res_page = dentry_page; - else - kunmap(dentry_page); return de; } @@ -287,7 +285,6 @@ ino_t f2fs_inode_by_name(struct inode *dir, const struct qstr *qstr, de = f2fs_find_entry(dir, qstr, page); if (de) { res = le32_to_cpu(de->ino); - f2fs_dentry_kunmap(dir, *page); f2fs_put_page(*page, 0); } @@ -302,7 +299,6 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de, f2fs_wait_on_page_writeback(page, type, true); de->ino = cpu_to_le32(inode->i_ino); set_de_type(de, inode->i_mode); - f2fs_dentry_kunmap(dir, page); set_page_dirty(page); dir->i_mtime = dir->i_ctime = current_time(dir); @@ -350,13 +346,11 @@ static int make_empty_dir(struct inode *inode, if (IS_ERR(dentry_page)) return PTR_ERR(dentry_page); - dentry_blk = kmap_atomic(dentry_page); + dentry_blk = page_address(dentry_page); make_dentry_ptr_block(NULL, , dentry_blk); do_make_empty_dir(inode, parent, ); - kunmap_atomic(dentry_blk); - set_page_dirty(dentry_page); f2fs_put_page(dentry_page, 1); return 0; @@ -547,13 +541,12 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name, if (IS_ERR(dentry_page)) return PTR_ERR(dentry_page); - dentry_blk = kmap(dentry_page); + dentry_blk = page_address(dentry_page); bit_pos = room_for_filename(_blk->dentry_bitmap, slots, NR_DENTRY_IN_BLOCK); if (bit_pos < NR_DENTRY_IN_BLOCK) goto add_dentry; - kunmap(dentry_page); f2fs_put_page(dentry_page, 1); } @@ -588,7 +581,6 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name, if (inode) up_write(_I(inode)->i_sem); - kunmap(dentry_page); f2fs_put_page(dentry_page, 1); return err; @@ -642,7 +634,6 @@ int __f2fs_add_link(struct inode *dir, const struct qstr *name, F2FS_I(dir)->task = NULL; } if (de) { - f2fs_dentry_kunmap(dir, page); f2fs_put_page(page, 0); err = -EEXIST; } else if (IS_ERR(page)) { @@ -730,7 +721,6 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page, bit_pos = find_next_bit_le(_blk->dentry_bitmap, NR_DENTRY_IN_BLOCK, 0); - kunmap(page); /* kunmap - pair of f2fs_find_entry */ set_page_dirty(page); dir->i_ctime = dir->i_mtime = current_time(dir); @@ -775,7 +765,7 @@ bool f2fs_empty_dir(struct inode *dir) return false; } - dentry_blk = kmap_atomic(dentry_page); + dentry_blk = page_address(dentry_page); if (bidx == 0) bit_pos = 2; else @@ -783,7 +773,6 @@ bool f2fs_empty_dir(struct inode *dir) bit_pos = find_next_bit_le(_blk->dentry_bitmap, NR_DENTRY_IN_BLOCK, bit_pos); - kunmap_atomic(dentry_blk); f2fs_put_page(dentry_page, 1); @@ -901,19 +890,17
Re: [PATCH] f2fs: don't put dentry page in pagecache into highmem
Hi, Jaegeuk, I find this patch is removed from current branch of dev-test recently, why? Any bugs? On 2018/2/28 20:31, Yunlong Song wrote: Previous dentry page uses highmem, which will cause panic in platforms using highmem (such as arm), since the address space of dentry pages from highmem directly goes into the decryption path via the function fscrypt_fname_disk_to_usr. But sg_init_one assumes the address is not from highmem, and then cause panic since it doesn't call kmap_high but kunmap_high is triggered at the end. To fix this problem in a simple way, this patch avoids to put dentry page in pagecache into highmem. Signed-off-by: Yunlong Song --- fs/f2fs/dir.c | 23 +-- fs/f2fs/f2fs.h | 6 -- fs/f2fs/inline.c| 3 +-- fs/f2fs/inode.c | 2 +- fs/f2fs/namei.c | 14 +- fs/f2fs/recovery.c | 11 +-- include/linux/f2fs_fs.h | 1 - 7 files changed, 13 insertions(+), 47 deletions(-) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index f00b5ed..797eb05 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -94,14 +94,12 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, struct f2fs_dir_entry *de; struct f2fs_dentry_ptr d; - dentry_blk = (struct f2fs_dentry_block *)kmap(dentry_page); + dentry_blk = (struct f2fs_dentry_block *)page_address(dentry_page); make_dentry_ptr_block(NULL, , dentry_blk); de = find_target_dentry(fname, namehash, max_slots, ); if (de) *res_page = dentry_page; - else - kunmap(dentry_page); return de; } @@ -287,7 +285,6 @@ ino_t f2fs_inode_by_name(struct inode *dir, const struct qstr *qstr, de = f2fs_find_entry(dir, qstr, page); if (de) { res = le32_to_cpu(de->ino); - f2fs_dentry_kunmap(dir, *page); f2fs_put_page(*page, 0); } @@ -302,7 +299,6 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de, f2fs_wait_on_page_writeback(page, type, true); de->ino = cpu_to_le32(inode->i_ino); set_de_type(de, inode->i_mode); - f2fs_dentry_kunmap(dir, page); set_page_dirty(page); dir->i_mtime = dir->i_ctime = current_time(dir); @@ -350,13 +346,11 @@ static int make_empty_dir(struct inode *inode, if (IS_ERR(dentry_page)) return PTR_ERR(dentry_page); - dentry_blk = kmap_atomic(dentry_page); + dentry_blk = page_address(dentry_page); make_dentry_ptr_block(NULL, , dentry_blk); do_make_empty_dir(inode, parent, ); - kunmap_atomic(dentry_blk); - set_page_dirty(dentry_page); f2fs_put_page(dentry_page, 1); return 0; @@ -547,13 +541,12 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name, if (IS_ERR(dentry_page)) return PTR_ERR(dentry_page); - dentry_blk = kmap(dentry_page); + dentry_blk = page_address(dentry_page); bit_pos = room_for_filename(_blk->dentry_bitmap, slots, NR_DENTRY_IN_BLOCK); if (bit_pos < NR_DENTRY_IN_BLOCK) goto add_dentry; - kunmap(dentry_page); f2fs_put_page(dentry_page, 1); } @@ -588,7 +581,6 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name, if (inode) up_write(_I(inode)->i_sem); - kunmap(dentry_page); f2fs_put_page(dentry_page, 1); return err; @@ -642,7 +634,6 @@ int __f2fs_add_link(struct inode *dir, const struct qstr *name, F2FS_I(dir)->task = NULL; } if (de) { - f2fs_dentry_kunmap(dir, page); f2fs_put_page(page, 0); err = -EEXIST; } else if (IS_ERR(page)) { @@ -730,7 +721,6 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page, bit_pos = find_next_bit_le(_blk->dentry_bitmap, NR_DENTRY_IN_BLOCK, 0); - kunmap(page); /* kunmap - pair of f2fs_find_entry */ set_page_dirty(page); dir->i_ctime = dir->i_mtime = current_time(dir); @@ -775,7 +765,7 @@ bool f2fs_empty_dir(struct inode *dir) return false; } - dentry_blk = kmap_atomic(dentry_page); + dentry_blk = page_address(dentry_page); if (bidx == 0) bit_pos = 2; else @@ -783,7 +773,6 @@ bool f2fs_empty_dir(struct inode *dir) bit_pos = find_next_bit_le(_blk->dentry_bitmap, NR_DENTRY_IN_BLOCK, bit_pos); - kunmap_atomic(dentry_blk); f2fs_put_page(dentry_page, 1); @@ -901,19 +890,17 @@ static int
Re: [PATCH] f2fs: don't put dentry page in pagecache into highmem
On 2018/2/28 20:31, Yunlong Song wrote: > Previous dentry page uses highmem, which will cause panic in platforms > using highmem (such as arm), since the address space of dentry pages > from highmem directly goes into the decryption path via the function > fscrypt_fname_disk_to_usr. But sg_init_one assumes the address is not > from highmem, and then cause panic since it doesn't call kmap_high but > kunmap_high is triggered at the end. To fix this problem in a simple > way, this patch avoids to put dentry page in pagecache into highmem. > > Signed-off-by: Yunlong SongReviewed-by: Chao Yu Thanks,
Re: [PATCH] f2fs: don't put dentry page in pagecache into highmem
On 2018/2/28 20:31, Yunlong Song wrote: > Previous dentry page uses highmem, which will cause panic in platforms > using highmem (such as arm), since the address space of dentry pages > from highmem directly goes into the decryption path via the function > fscrypt_fname_disk_to_usr. But sg_init_one assumes the address is not > from highmem, and then cause panic since it doesn't call kmap_high but > kunmap_high is triggered at the end. To fix this problem in a simple > way, this patch avoids to put dentry page in pagecache into highmem. > > Signed-off-by: Yunlong Song Reviewed-by: Chao Yu Thanks,
[PATCH] f2fs: don't put dentry page in pagecache into highmem
Previous dentry page uses highmem, which will cause panic in platforms using highmem (such as arm), since the address space of dentry pages from highmem directly goes into the decryption path via the function fscrypt_fname_disk_to_usr. But sg_init_one assumes the address is not from highmem, and then cause panic since it doesn't call kmap_high but kunmap_high is triggered at the end. To fix this problem in a simple way, this patch avoids to put dentry page in pagecache into highmem. Signed-off-by: Yunlong Song--- fs/f2fs/dir.c | 23 +-- fs/f2fs/f2fs.h | 6 -- fs/f2fs/inline.c| 3 +-- fs/f2fs/inode.c | 2 +- fs/f2fs/namei.c | 14 +- fs/f2fs/recovery.c | 11 +-- include/linux/f2fs_fs.h | 1 - 7 files changed, 13 insertions(+), 47 deletions(-) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index f00b5ed..797eb05 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -94,14 +94,12 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, struct f2fs_dir_entry *de; struct f2fs_dentry_ptr d; - dentry_blk = (struct f2fs_dentry_block *)kmap(dentry_page); + dentry_blk = (struct f2fs_dentry_block *)page_address(dentry_page); make_dentry_ptr_block(NULL, , dentry_blk); de = find_target_dentry(fname, namehash, max_slots, ); if (de) *res_page = dentry_page; - else - kunmap(dentry_page); return de; } @@ -287,7 +285,6 @@ ino_t f2fs_inode_by_name(struct inode *dir, const struct qstr *qstr, de = f2fs_find_entry(dir, qstr, page); if (de) { res = le32_to_cpu(de->ino); - f2fs_dentry_kunmap(dir, *page); f2fs_put_page(*page, 0); } @@ -302,7 +299,6 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de, f2fs_wait_on_page_writeback(page, type, true); de->ino = cpu_to_le32(inode->i_ino); set_de_type(de, inode->i_mode); - f2fs_dentry_kunmap(dir, page); set_page_dirty(page); dir->i_mtime = dir->i_ctime = current_time(dir); @@ -350,13 +346,11 @@ static int make_empty_dir(struct inode *inode, if (IS_ERR(dentry_page)) return PTR_ERR(dentry_page); - dentry_blk = kmap_atomic(dentry_page); + dentry_blk = page_address(dentry_page); make_dentry_ptr_block(NULL, , dentry_blk); do_make_empty_dir(inode, parent, ); - kunmap_atomic(dentry_blk); - set_page_dirty(dentry_page); f2fs_put_page(dentry_page, 1); return 0; @@ -547,13 +541,12 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name, if (IS_ERR(dentry_page)) return PTR_ERR(dentry_page); - dentry_blk = kmap(dentry_page); + dentry_blk = page_address(dentry_page); bit_pos = room_for_filename(_blk->dentry_bitmap, slots, NR_DENTRY_IN_BLOCK); if (bit_pos < NR_DENTRY_IN_BLOCK) goto add_dentry; - kunmap(dentry_page); f2fs_put_page(dentry_page, 1); } @@ -588,7 +581,6 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name, if (inode) up_write(_I(inode)->i_sem); - kunmap(dentry_page); f2fs_put_page(dentry_page, 1); return err; @@ -642,7 +634,6 @@ int __f2fs_add_link(struct inode *dir, const struct qstr *name, F2FS_I(dir)->task = NULL; } if (de) { - f2fs_dentry_kunmap(dir, page); f2fs_put_page(page, 0); err = -EEXIST; } else if (IS_ERR(page)) { @@ -730,7 +721,6 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page, bit_pos = find_next_bit_le(_blk->dentry_bitmap, NR_DENTRY_IN_BLOCK, 0); - kunmap(page); /* kunmap - pair of f2fs_find_entry */ set_page_dirty(page); dir->i_ctime = dir->i_mtime = current_time(dir); @@ -775,7 +765,7 @@ bool f2fs_empty_dir(struct inode *dir) return false; } - dentry_blk = kmap_atomic(dentry_page); + dentry_blk = page_address(dentry_page); if (bidx == 0) bit_pos = 2; else @@ -783,7 +773,6 @@ bool f2fs_empty_dir(struct inode *dir) bit_pos = find_next_bit_le(_blk->dentry_bitmap, NR_DENTRY_IN_BLOCK, bit_pos); - kunmap_atomic(dentry_blk); f2fs_put_page(dentry_page, 1); @@ -901,19 +890,17 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
[PATCH] f2fs: don't put dentry page in pagecache into highmem
Previous dentry page uses highmem, which will cause panic in platforms using highmem (such as arm), since the address space of dentry pages from highmem directly goes into the decryption path via the function fscrypt_fname_disk_to_usr. But sg_init_one assumes the address is not from highmem, and then cause panic since it doesn't call kmap_high but kunmap_high is triggered at the end. To fix this problem in a simple way, this patch avoids to put dentry page in pagecache into highmem. Signed-off-by: Yunlong Song --- fs/f2fs/dir.c | 23 +-- fs/f2fs/f2fs.h | 6 -- fs/f2fs/inline.c| 3 +-- fs/f2fs/inode.c | 2 +- fs/f2fs/namei.c | 14 +- fs/f2fs/recovery.c | 11 +-- include/linux/f2fs_fs.h | 1 - 7 files changed, 13 insertions(+), 47 deletions(-) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index f00b5ed..797eb05 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -94,14 +94,12 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, struct f2fs_dir_entry *de; struct f2fs_dentry_ptr d; - dentry_blk = (struct f2fs_dentry_block *)kmap(dentry_page); + dentry_blk = (struct f2fs_dentry_block *)page_address(dentry_page); make_dentry_ptr_block(NULL, , dentry_blk); de = find_target_dentry(fname, namehash, max_slots, ); if (de) *res_page = dentry_page; - else - kunmap(dentry_page); return de; } @@ -287,7 +285,6 @@ ino_t f2fs_inode_by_name(struct inode *dir, const struct qstr *qstr, de = f2fs_find_entry(dir, qstr, page); if (de) { res = le32_to_cpu(de->ino); - f2fs_dentry_kunmap(dir, *page); f2fs_put_page(*page, 0); } @@ -302,7 +299,6 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de, f2fs_wait_on_page_writeback(page, type, true); de->ino = cpu_to_le32(inode->i_ino); set_de_type(de, inode->i_mode); - f2fs_dentry_kunmap(dir, page); set_page_dirty(page); dir->i_mtime = dir->i_ctime = current_time(dir); @@ -350,13 +346,11 @@ static int make_empty_dir(struct inode *inode, if (IS_ERR(dentry_page)) return PTR_ERR(dentry_page); - dentry_blk = kmap_atomic(dentry_page); + dentry_blk = page_address(dentry_page); make_dentry_ptr_block(NULL, , dentry_blk); do_make_empty_dir(inode, parent, ); - kunmap_atomic(dentry_blk); - set_page_dirty(dentry_page); f2fs_put_page(dentry_page, 1); return 0; @@ -547,13 +541,12 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name, if (IS_ERR(dentry_page)) return PTR_ERR(dentry_page); - dentry_blk = kmap(dentry_page); + dentry_blk = page_address(dentry_page); bit_pos = room_for_filename(_blk->dentry_bitmap, slots, NR_DENTRY_IN_BLOCK); if (bit_pos < NR_DENTRY_IN_BLOCK) goto add_dentry; - kunmap(dentry_page); f2fs_put_page(dentry_page, 1); } @@ -588,7 +581,6 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name, if (inode) up_write(_I(inode)->i_sem); - kunmap(dentry_page); f2fs_put_page(dentry_page, 1); return err; @@ -642,7 +634,6 @@ int __f2fs_add_link(struct inode *dir, const struct qstr *name, F2FS_I(dir)->task = NULL; } if (de) { - f2fs_dentry_kunmap(dir, page); f2fs_put_page(page, 0); err = -EEXIST; } else if (IS_ERR(page)) { @@ -730,7 +721,6 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page, bit_pos = find_next_bit_le(_blk->dentry_bitmap, NR_DENTRY_IN_BLOCK, 0); - kunmap(page); /* kunmap - pair of f2fs_find_entry */ set_page_dirty(page); dir->i_ctime = dir->i_mtime = current_time(dir); @@ -775,7 +765,7 @@ bool f2fs_empty_dir(struct inode *dir) return false; } - dentry_blk = kmap_atomic(dentry_page); + dentry_blk = page_address(dentry_page); if (bidx == 0) bit_pos = 2; else @@ -783,7 +773,6 @@ bool f2fs_empty_dir(struct inode *dir) bit_pos = find_next_bit_le(_blk->dentry_bitmap, NR_DENTRY_IN_BLOCK, bit_pos); - kunmap_atomic(dentry_blk); f2fs_put_page(dentry_page, 1); @@ -901,19 +890,17 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx) }