Skip to content

Commit ec4f59d

Browse files
committed
erofs: get rid of buf->kmap_type
After commit 927e501 ("erofs: use kmap_local_page() only for erofs_bread()"), `buf->kmap_type` actually has no use at all. Let's get rid of `buf->kmap_type` now. Suggested-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> Link: https://lore.kernel.org/r/20241114095813.839866-1-hsiangkao@linux.alibaba.com
1 parent 3a23787 commit ec4f59d

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

fs/erofs/data.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
void erofs_unmap_metabuf(struct erofs_buf *buf)
1212
{
13-
if (buf->kmap_type == EROFS_KMAP)
14-
kunmap_local(buf->base);
13+
if (!buf->base)
14+
return;
15+
kunmap_local(buf->base);
1516
buf->base = NULL;
16-
buf->kmap_type = EROFS_NO_KMAP;
1717
}
1818

1919
void erofs_put_metabuf(struct erofs_buf *buf)
@@ -43,15 +43,8 @@ void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset,
4343
return folio;
4444
}
4545
buf->page = folio_file_page(folio, index);
46-
47-
if (buf->kmap_type == EROFS_NO_KMAP) {
48-
if (type == EROFS_KMAP)
49-
buf->base = kmap_local_page(buf->page);
50-
buf->kmap_type = type;
51-
} else if (buf->kmap_type != type) {
52-
DBG_BUGON(1);
53-
return ERR_PTR(-EFAULT);
54-
}
46+
if (!buf->base && type == EROFS_KMAP)
47+
buf->base = kmap_local_page(buf->page);
5548
if (type == EROFS_NO_KMAP)
5649
return NULL;
5750
return buf->base + (offset & ~PAGE_MASK);
@@ -352,7 +345,6 @@ static int erofs_iomap_end(struct inode *inode, loff_t pos, loff_t length,
352345
struct erofs_buf buf = {
353346
.page = kmap_to_page(ptr),
354347
.base = ptr,
355-
.kmap_type = EROFS_KMAP,
356348
};
357349

358350
DBG_BUGON(iomap->type != IOMAP_INLINE);

fs/erofs/internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ struct erofs_buf {
212212
struct file *file;
213213
struct page *page;
214214
void *base;
215-
enum erofs_kmap_type kmap_type;
216215
};
217216
#define __EROFS_BUF_INITIALIZER ((struct erofs_buf){ .page = NULL })
218217

0 commit comments

Comments
 (0)