* [PATCH] erofs: use kmap_local_page() only for erofs_bread()
@ 2022-10-18 3:55 Gao Xiang
2022-10-18 6:47 ` JeffleXu
[not found] ` <202210181728.gXrmc8LC-lkp@intel.com>
0 siblings, 2 replies; 3+ messages in thread
From: Gao Xiang @ 2022-10-18 3:55 UTC (permalink / raw)
To: linux-erofs, Chao Yu; +Cc: Gao Xiang, LKML
Convert all mapped erofs_bread() users to use kmap_local_page()
instead of kmap() or kmap_atomic().
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
fs/erofs/data.c | 8 ++------
fs/erofs/internal.h | 3 +--
fs/erofs/xattr.c | 8 ++++----
fs/erofs/zmap.c | 4 ++--
4 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index fe8ac0e163f7..3873395173b5 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -13,9 +13,7 @@
void erofs_unmap_metabuf(struct erofs_buf *buf)
{
if (buf->kmap_type == EROFS_KMAP)
- kunmap(buf->page);
- else if (buf->kmap_type == EROFS_KMAP_ATOMIC)
- kunmap_atomic(buf->base);
+ kunmap_local(buf->page);
buf->base = NULL;
buf->kmap_type = EROFS_NO_KMAP;
}
@@ -54,9 +52,7 @@ void *erofs_bread(struct erofs_buf *buf, struct inode *inode,
}
if (buf->kmap_type == EROFS_NO_KMAP) {
if (type == EROFS_KMAP)
- buf->base = kmap(page);
- else if (type == EROFS_KMAP_ATOMIC)
- buf->base = kmap_atomic(page);
+ buf->base = kmap_local_page(page);
buf->kmap_type = type;
} else if (buf->kmap_type != type) {
DBG_BUGON(1);
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 1701df48c446..67dc8e177211 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -253,8 +253,7 @@ static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp)
enum erofs_kmap_type {
EROFS_NO_KMAP, /* don't map the buffer */
- EROFS_KMAP, /* use kmap() to map the buffer */
- EROFS_KMAP_ATOMIC, /* use kmap_atomic() to map the buffer */
+ EROFS_KMAP, /* use kmap_local_page() to map the buffer */
};
struct erofs_buf {
diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
index 8106bcb5a38d..a62fb8a3318a 100644
--- a/fs/erofs/xattr.c
+++ b/fs/erofs/xattr.c
@@ -148,7 +148,7 @@ static inline int xattr_iter_fixup(struct xattr_iter *it)
it->blkaddr += erofs_blknr(it->ofs);
it->kaddr = erofs_read_metabuf(&it->buf, it->sb, it->blkaddr,
- EROFS_KMAP_ATOMIC);
+ EROFS_KMAP);
if (IS_ERR(it->kaddr))
return PTR_ERR(it->kaddr);
it->ofs = erofs_blkoff(it->ofs);
@@ -174,7 +174,7 @@ static int inline_xattr_iter_begin(struct xattr_iter *it,
it->ofs = erofs_blkoff(iloc(sbi, vi->nid) + inline_xattr_ofs);
it->kaddr = erofs_read_metabuf(&it->buf, inode->i_sb, it->blkaddr,
- EROFS_KMAP_ATOMIC);
+ EROFS_KMAP);
if (IS_ERR(it->kaddr))
return PTR_ERR(it->kaddr);
return vi->xattr_isize - xattr_header_sz;
@@ -368,7 +368,7 @@ static int shared_getxattr(struct inode *inode, struct getxattr_iter *it)
it->it.ofs = xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]);
it->it.kaddr = erofs_read_metabuf(&it->it.buf, sb, blkaddr,
- EROFS_KMAP_ATOMIC);
+ EROFS_KMAP);
if (IS_ERR(it->it.kaddr))
return PTR_ERR(it->it.kaddr);
it->it.blkaddr = blkaddr;
@@ -580,7 +580,7 @@ static int shared_listxattr(struct listxattr_iter *it)
it->it.ofs = xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]);
it->it.kaddr = erofs_read_metabuf(&it->it.buf, sb, blkaddr,
- EROFS_KMAP_ATOMIC);
+ EROFS_KMAP);
if (IS_ERR(it->it.kaddr))
return PTR_ERR(it->it.kaddr);
it->it.blkaddr = blkaddr;
diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
index 0bb66927e3d0..749a5ac943f4 100644
--- a/fs/erofs/zmap.c
+++ b/fs/erofs/zmap.c
@@ -178,7 +178,7 @@ static int legacy_load_cluster_from_disk(struct z_erofs_maprecorder *m,
unsigned int advise, type;
m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb,
- erofs_blknr(pos), EROFS_KMAP_ATOMIC);
+ erofs_blknr(pos), EROFS_KMAP);
if (IS_ERR(m->kaddr))
return PTR_ERR(m->kaddr);
@@ -416,7 +416,7 @@ static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m,
out:
pos += lcn * (1 << amortizedshift);
m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb,
- erofs_blknr(pos), EROFS_KMAP_ATOMIC);
+ erofs_blknr(pos), EROFS_KMAP);
if (IS_ERR(m->kaddr))
return PTR_ERR(m->kaddr);
return unpack_compacted_index(m, amortizedshift, pos, lookahead);
--
2.24.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] erofs: use kmap_local_page() only for erofs_bread()
2022-10-18 3:55 [PATCH] erofs: use kmap_local_page() only for erofs_bread() Gao Xiang
@ 2022-10-18 6:47 ` JeffleXu
[not found] ` <202210181728.gXrmc8LC-lkp@intel.com>
1 sibling, 0 replies; 3+ messages in thread
From: JeffleXu @ 2022-10-18 6:47 UTC (permalink / raw)
To: Gao Xiang, linux-erofs, Chao Yu; +Cc: LKML
On 10/18/22 11:55 AM, Gao Xiang wrote:
> Convert all mapped erofs_bread() users to use kmap_local_page()
> instead of kmap() or kmap_atomic().
>
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
LGTM.
Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
> ---
> fs/erofs/data.c | 8 ++------
> fs/erofs/internal.h | 3 +--
> fs/erofs/xattr.c | 8 ++++----
> fs/erofs/zmap.c | 4 ++--
> 4 files changed, 9 insertions(+), 14 deletions(-)
>
> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
> index fe8ac0e163f7..3873395173b5 100644
> --- a/fs/erofs/data.c
> +++ b/fs/erofs/data.c
> @@ -13,9 +13,7 @@
> void erofs_unmap_metabuf(struct erofs_buf *buf)
> {
> if (buf->kmap_type == EROFS_KMAP)
> - kunmap(buf->page);
> - else if (buf->kmap_type == EROFS_KMAP_ATOMIC)
> - kunmap_atomic(buf->base);
> + kunmap_local(buf->page);
> buf->base = NULL;
> buf->kmap_type = EROFS_NO_KMAP;
> }
> @@ -54,9 +52,7 @@ void *erofs_bread(struct erofs_buf *buf, struct inode *inode,
> }
> if (buf->kmap_type == EROFS_NO_KMAP) {
> if (type == EROFS_KMAP)
> - buf->base = kmap(page);
> - else if (type == EROFS_KMAP_ATOMIC)
> - buf->base = kmap_atomic(page);
> + buf->base = kmap_local_page(page);
> buf->kmap_type = type;
> } else if (buf->kmap_type != type) {
> DBG_BUGON(1);
> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
> index 1701df48c446..67dc8e177211 100644
> --- a/fs/erofs/internal.h
> +++ b/fs/erofs/internal.h
> @@ -253,8 +253,7 @@ static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp)
>
> enum erofs_kmap_type {
> EROFS_NO_KMAP, /* don't map the buffer */
> - EROFS_KMAP, /* use kmap() to map the buffer */
> - EROFS_KMAP_ATOMIC, /* use kmap_atomic() to map the buffer */
> + EROFS_KMAP, /* use kmap_local_page() to map the buffer */
> };
>
> struct erofs_buf {
> diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
> index 8106bcb5a38d..a62fb8a3318a 100644
> --- a/fs/erofs/xattr.c
> +++ b/fs/erofs/xattr.c
> @@ -148,7 +148,7 @@ static inline int xattr_iter_fixup(struct xattr_iter *it)
>
> it->blkaddr += erofs_blknr(it->ofs);
> it->kaddr = erofs_read_metabuf(&it->buf, it->sb, it->blkaddr,
> - EROFS_KMAP_ATOMIC);
> + EROFS_KMAP);
> if (IS_ERR(it->kaddr))
> return PTR_ERR(it->kaddr);
> it->ofs = erofs_blkoff(it->ofs);
> @@ -174,7 +174,7 @@ static int inline_xattr_iter_begin(struct xattr_iter *it,
> it->ofs = erofs_blkoff(iloc(sbi, vi->nid) + inline_xattr_ofs);
>
> it->kaddr = erofs_read_metabuf(&it->buf, inode->i_sb, it->blkaddr,
> - EROFS_KMAP_ATOMIC);
> + EROFS_KMAP);
> if (IS_ERR(it->kaddr))
> return PTR_ERR(it->kaddr);
> return vi->xattr_isize - xattr_header_sz;
> @@ -368,7 +368,7 @@ static int shared_getxattr(struct inode *inode, struct getxattr_iter *it)
>
> it->it.ofs = xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]);
> it->it.kaddr = erofs_read_metabuf(&it->it.buf, sb, blkaddr,
> - EROFS_KMAP_ATOMIC);
> + EROFS_KMAP);
> if (IS_ERR(it->it.kaddr))
> return PTR_ERR(it->it.kaddr);
> it->it.blkaddr = blkaddr;
> @@ -580,7 +580,7 @@ static int shared_listxattr(struct listxattr_iter *it)
>
> it->it.ofs = xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]);
> it->it.kaddr = erofs_read_metabuf(&it->it.buf, sb, blkaddr,
> - EROFS_KMAP_ATOMIC);
> + EROFS_KMAP);
> if (IS_ERR(it->it.kaddr))
> return PTR_ERR(it->it.kaddr);
> it->it.blkaddr = blkaddr;
> diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
> index 0bb66927e3d0..749a5ac943f4 100644
> --- a/fs/erofs/zmap.c
> +++ b/fs/erofs/zmap.c
> @@ -178,7 +178,7 @@ static int legacy_load_cluster_from_disk(struct z_erofs_maprecorder *m,
> unsigned int advise, type;
>
> m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb,
> - erofs_blknr(pos), EROFS_KMAP_ATOMIC);
> + erofs_blknr(pos), EROFS_KMAP);
> if (IS_ERR(m->kaddr))
> return PTR_ERR(m->kaddr);
>
> @@ -416,7 +416,7 @@ static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m,
> out:
> pos += lcn * (1 << amortizedshift);
> m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb,
> - erofs_blknr(pos), EROFS_KMAP_ATOMIC);
> + erofs_blknr(pos), EROFS_KMAP);
> if (IS_ERR(m->kaddr))
> return PTR_ERR(m->kaddr);
> return unpack_compacted_index(m, amortizedshift, pos, lookahead);
--
Thanks,
Jingbo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] erofs: use kmap_local_page() only for erofs_bread()
[not found] ` <202210181728.gXrmc8LC-lkp@intel.com>
@ 2022-10-18 9:48 ` Gao Xiang
0 siblings, 0 replies; 3+ messages in thread
From: Gao Xiang @ 2022-10-18 9:48 UTC (permalink / raw)
To: kernel test robot; +Cc: kbuild-all, Chao Yu, linux-erofs, LKML
On Tue, Oct 18, 2022 at 05:22:18PM +0800, kernel test robot wrote:
> Hi Gao,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on xiang-erofs/dev-test]
> [also build test ERROR on linus/master v6.1-rc1 next-20221018]
Thanks for the report, sorry for submitting an outdated version.
I'll merge the latest update and resend.
Thanks,
Gao Xiang
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-18 9:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-18 3:55 [PATCH] erofs: use kmap_local_page() only for erofs_bread() Gao Xiang
2022-10-18 6:47 ` JeffleXu
[not found] ` <202210181728.gXrmc8LC-lkp@intel.com>
2022-10-18 9:48 ` Gao Xiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox