fs/ext4: Replace kmap_atomic() with kmap_local_page()
Subsystems (2)
PATCH 1/1 fs/ext4: Replace kmap_atomic() with kmap_local_page()
kmap_atomic() is deprecated in favor of kmap_local_page(). Therefore, replace kmap_atomic() with kmap_local_page().
kmap_atomic() is implemented like a kmap_local_page() which also disables page-faults and preemption (the latter only for !PREEMPT_RT kernels).
However, the code within the mappings and un-mappings in ext4/inline.c does not depend on the above-mentioned side effects.
Therefore, a mere replacement of the old API with the new one is all it is required (i.e., there is no need to explicitly add any calls to pagefault_disable() and/or preempt_disable()).
---
I tried my best to understand the code within mapping and un-mapping. However, I'm not an expert. Therefore, although I'm pretty confident, I cannot be 100% sure that the code between the mapping and the un-mapping does not depend on pagefault_disable() and/or preempt_disable().
Unfortunately, I cannot currently test this changes to check the above-mentioned assumptions. However, if I'm required to do the tests with (x)fstests, I have no problems with doing them in the next days.
If so, I'll test in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel with HIGHMEM64GB enabled.
I'd like to hear whether or not the maintainers require these tests and/or other tests.
fs/ext4/inline.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
fs/ext4/inline.c +6 -6
@@ -490,10 +490,10 @@ static int ext4_read_inline_page(struct inode *inode, struct page *page) goto out; len =min_t (size_t,ext4_get_inline_size (inode),i_size_read (inode)); - kaddr =kmap_atomic (page); + kaddr =kmap_local_page (page); ret =ext4_read_inline_data (inode, kaddr, len, &iloc);flush_dcache_page (page); -kunmap_atomic (kaddr); +kunmap_local (kaddr);zero_user_segment (page, len,PAGE_SIZE );SetPageUptodate (page);brelse (iloc.bh);
@@ -763,9 +763,9 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,*/ (void )ext4_find_inline_data_nolock (inode); - kaddr =kmap_atomic (page); + kaddr =kmap_local_page (page);ext4_write_inline_data (inode, &iloc, kaddr, pos, copied); -kunmap_atomic (kaddr); +kunmap_local (kaddr);SetPageUptodate (page);/* clear page dirty so that writepages wouldn't work for us. */ ClearPageDirty (page);
@@ -831,9 +831,9 @@ ext4_journalled_write_inline_data(struct inode *inode, }ext4_write_lock_xattr (inode, &no_expand); - kaddr =kmap_atomic (page); + kaddr =kmap_local_page (page);ext4_write_inline_data (inode, &iloc, kaddr,0 , len); -kunmap_atomic (kaddr); +kunmap_local (kaddr);ext4_write_unlock_xattr (inode, &no_expand);return iloc.bh;
Signature · 1 line
2.39.0
Quoted 9 lines · Fabio M. De Francesco
kmap_atomic()is deprecated in favor ofkmap_local_page(). Therefore, replacekmap_atomic()withkmap_local_page().
kmap_atomic()is implemented like akmap_local_page()which also disables page-faults and preemption (the latter only for !PREEMPT_RT kernels).However, the code within the mappings and un-mappings in
ext4/inline.cdoes not depend on the above-mentioned side effects.
Quoted 6 lines
Therefore, a mere replacement of the old API with the new one is all it is required (i.e., there is no need to explicitly add any calls to
pagefault_disable()and/orpreempt_disable()).Suggested-by Ira Weiny <[email protected]>Signed-off-by Fabio M. De Francesco <[email protected]>
The patch looks good to me. Feel free to add:
Honza
Quoted 64 lines
---
I tried my best to understand the code within mapping and un-mapping. However, I'm not an expert. Therefore, although I'm pretty confident, I cannot be 100% sure that the code between the mapping and the un-mapping does not depend on
pagefault_disable()and/orpreempt_disable().Unfortunately, I cannot currently test this changes to check the above-mentioned assumptions. However, if I'm required to do the tests with (x)fstests, I have no problems with doing them in the next days.
If so, I'll test in a QEMU/KVM
x86_32VM, 6GB RAM, booting a kernel with HIGHMEM64GB enabled.I'd like to hear whether or not the maintainers require these tests and/or other tests.
fs/ext4/inline.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)fs/ext4/inline.c +6
-6@@ -490,10 +490,10 @@ static int ext4_read_inline_page(struct inode *inode, struct page *page) goto out; len =min_t (size_t,ext4_get_inline_size (inode),i_size_read (inode)); - kaddr =kmap_atomic (page); + kaddr =kmap_local_page (page); ret =ext4_read_inline_data (inode, kaddr, len, &iloc);flush_dcache_page (page); -kunmap_atomic (kaddr); +kunmap_local (kaddr);zero_user_segment (page, len,PAGE_SIZE );SetPageUptodate (page);brelse (iloc.bh);@@ -763,9 +763,9 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,*/ (void )ext4_find_inline_data_nolock (inode); - kaddr =kmap_atomic (page); + kaddr =kmap_local_page (page);ext4_write_inline_data (inode, &iloc, kaddr, pos, copied); -kunmap_atomic (kaddr); +kunmap_local (kaddr);SetPageUptodate (page);/* clear page dirty so that writepages wouldn't work for us. */ ClearPageDirty (page);@@ -831,9 +831,9 @@ ext4_journalled_write_inline_data(struct inode *inode, }ext4_write_lock_xattr (inode, &no_expand); - kaddr =kmap_atomic (page); + kaddr =kmap_local_page (page);ext4_write_inline_data (inode, &iloc, kaddr,0 , len); -kunmap_atomic (kaddr); +kunmap_local (kaddr);ext4_write_unlock_xattr (inode, &no_expand);return iloc.bh;Signature · 1 line
2.39.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 6 lines · Fabio M. De Francesco
kmap_atomic()is deprecated in favor ofkmap_local_page(). Therefore, replacekmap_atomic()withkmap_local_page().
kmap_atomic()is implemented like akmap_local_page()which also disables page-faults and preemption (the latter only for !PREEMPT_RT kernels).
Quoted 8 lines
However, the code within the mappings and un-mappings in
ext4/inline.cdoes not depend on the above-mentioned side effects.Therefore, a mere replacement of the old API with the new one is all it is required (i.e., there is no need to explicitly add any calls to
pagefault_disable()and/orpreempt_disable()).Suggested-by Ira Weiny <[email protected]>
Quoted 65 lines
Signed-off-by Fabio M. De Francesco <[email protected]>---
I tried my best to understand the code within mapping and un-mapping. However, I'm not an expert. Therefore, although I'm pretty confident, I cannot be 100% sure that the code between the mapping and the un-mapping does not depend on
pagefault_disable()and/orpreempt_disable().Unfortunately, I cannot currently test this changes to check the above-mentioned assumptions. However, if I'm required to do the tests with (x)fstests, I have no problems with doing them in the next days.
If so, I'll test in a QEMU/KVM
x86_32VM, 6GB RAM, booting a kernel with HIGHMEM64GB enabled.I'd like to hear whether or not the maintainers require these tests and/or other tests.
fs/ext4/inline.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)fs/ext4/inline.c +6
-6@@ -490,10 +490,10 @@ static int ext4_read_inline_page(struct inode *inode, struct page *page) goto out; len =min_t (size_t,ext4_get_inline_size (inode),i_size_read (inode)); - kaddr =kmap_atomic (page); + kaddr =kmap_local_page (page); ret =ext4_read_inline_data (inode, kaddr, len, &iloc);flush_dcache_page (page); -kunmap_atomic (kaddr); +kunmap_local (kaddr);zero_user_segment (page, len,PAGE_SIZE );SetPageUptodate (page);brelse (iloc.bh);@@ -763,9 +763,9 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,*/ (void )ext4_find_inline_data_nolock (inode); - kaddr =kmap_atomic (page); + kaddr =kmap_local_page (page);ext4_write_inline_data (inode, &iloc, kaddr, pos, copied); -kunmap_atomic (kaddr); +kunmap_local (kaddr);SetPageUptodate (page);/* clear page dirty so that writepages wouldn't work for us. */ ClearPageDirty (page);@@ -831,9 +831,9 @@ ext4_journalled_write_inline_data(struct inode *inode, }ext4_write_lock_xattr (inode, &no_expand); - kaddr =kmap_atomic (page); + kaddr =kmap_local_page (page);ext4_write_inline_data (inode, &iloc, kaddr,0 , len); -kunmap_atomic (kaddr); +kunmap_local (kaddr);ext4_write_unlock_xattr (inode, &no_expand);return iloc.bh;Signature · 1 line
2.39.0