Skip to content

Commit 706e50e

Browse files
Bo Liuhsiangkao
authored andcommitted
erofs: get rid of erofs_kmap_type
Since EROFS_KMAP_ATOMIC is no longer valid, get rid of erofs_kmap_type too. Signed-off-by: Bo Liu <liubo03@inspur.com> Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> Reviewed-by: Chao Yu <chao@kernel.org> Link: https://lore.kernel.org/r/20250217093141.2659-1-liubo03@inspur.com Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
1 parent 3b7781a commit 706e50e

11 files changed

Lines changed: 32 additions & 39 deletions

File tree

fs/erofs/data.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ void erofs_put_metabuf(struct erofs_buf *buf)
2525
buf->page = NULL;
2626
}
2727

28-
void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset,
29-
enum erofs_kmap_type type)
28+
void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset, bool need_kmap)
3029
{
3130
pgoff_t index = offset >> PAGE_SHIFT;
3231
struct folio *folio = NULL;
@@ -43,10 +42,10 @@ void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset,
4342
return folio;
4443
}
4544
buf->page = folio_file_page(folio, index);
46-
if (!buf->base && type == EROFS_KMAP)
47-
buf->base = kmap_local_page(buf->page);
48-
if (type == EROFS_NO_KMAP)
45+
if (!need_kmap)
4946
return NULL;
47+
if (!buf->base)
48+
buf->base = kmap_local_page(buf->page);
5049
return buf->base + (offset & ~PAGE_MASK);
5150
}
5251

@@ -65,10 +64,10 @@ void erofs_init_metabuf(struct erofs_buf *buf, struct super_block *sb)
6564
}
6665

6766
void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb,
68-
erofs_off_t offset, enum erofs_kmap_type type)
67+
erofs_off_t offset, bool need_kmap)
6968
{
7069
erofs_init_metabuf(buf, sb);
71-
return erofs_bread(buf, offset, type);
70+
return erofs_bread(buf, offset, need_kmap);
7271
}
7372

7473
static int erofs_map_blocks_flatmode(struct inode *inode,
@@ -135,7 +134,7 @@ int erofs_map_blocks(struct inode *inode, struct erofs_map_blocks *map)
135134
pos = ALIGN(erofs_iloc(inode) + vi->inode_isize +
136135
vi->xattr_isize, unit) + unit * chunknr;
137136

138-
kaddr = erofs_read_metabuf(&buf, sb, pos, EROFS_KMAP);
137+
kaddr = erofs_read_metabuf(&buf, sb, pos, true);
139138
if (IS_ERR(kaddr)) {
140139
err = PTR_ERR(kaddr);
141140
goto out;
@@ -312,7 +311,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
312311
struct erofs_buf buf = __EROFS_BUF_INITIALIZER;
313312

314313
iomap->type = IOMAP_INLINE;
315-
ptr = erofs_read_metabuf(&buf, sb, mdev.m_pa, EROFS_KMAP);
314+
ptr = erofs_read_metabuf(&buf, sb, mdev.m_pa, true);
316315
if (IS_ERR(ptr))
317316
return PTR_ERR(ptr);
318317
iomap->inline_data = ptr;

fs/erofs/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx)
5858
struct erofs_dirent *de;
5959
unsigned int nameoff, maxsize;
6060

61-
de = erofs_bread(&buf, dbstart, EROFS_KMAP);
61+
de = erofs_bread(&buf, dbstart, true);
6262
if (IS_ERR(de)) {
6363
erofs_err(sb, "fail to readdir of logical block %u of nid %llu",
6464
erofs_blknr(sb, dbstart), EROFS_I(dir)->nid);

fs/erofs/fileio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static int erofs_fileio_scan_folio(struct erofs_fileio *io, struct folio *folio)
112112
void *src;
113113

114114
src = erofs_read_metabuf(&buf, inode->i_sb,
115-
map->m_pa + ofs, EROFS_KMAP);
115+
map->m_pa + ofs, true);
116116
if (IS_ERR(src)) {
117117
err = PTR_ERR(src);
118118
break;

fs/erofs/fscache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static int erofs_fscache_data_read_slice(struct erofs_fscache_rq *req)
276276
size_t size = map.m_llen;
277277
void *src;
278278

279-
src = erofs_read_metabuf(&buf, sb, map.m_pa, EROFS_KMAP);
279+
src = erofs_read_metabuf(&buf, sb, map.m_pa, true);
280280
if (IS_ERR(src))
281281
return PTR_ERR(src);
282282

fs/erofs/inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static int erofs_read_inode(struct inode *inode)
4242
blkaddr = erofs_blknr(sb, inode_loc);
4343
ofs = erofs_blkoff(sb, inode_loc);
4444

45-
kaddr = erofs_read_metabuf(&buf, sb, erofs_pos(sb, blkaddr), EROFS_KMAP);
45+
kaddr = erofs_read_metabuf(&buf, sb, erofs_pos(sb, blkaddr), true);
4646
if (IS_ERR(kaddr)) {
4747
erofs_err(sb, "failed to get inode (nid: %llu) page, err %ld",
4848
vi->nid, PTR_ERR(kaddr));
@@ -82,8 +82,8 @@ static int erofs_read_inode(struct inode *inode)
8282
goto err_out;
8383
}
8484
memcpy(copied, dic, gotten);
85-
kaddr = erofs_read_metabuf(&buf, sb, erofs_pos(sb, blkaddr + 1),
86-
EROFS_KMAP);
85+
kaddr = erofs_read_metabuf(&buf, sb,
86+
erofs_pos(sb, blkaddr + 1), true);
8787
if (IS_ERR(kaddr)) {
8888
erofs_err(sb, "failed to get inode payload block (nid: %llu), err %ld",
8989
vi->nid, PTR_ERR(kaddr));

fs/erofs/internal.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,6 @@ enum {
199199
EROFS_ZIP_CACHE_READAROUND
200200
};
201201

202-
enum erofs_kmap_type {
203-
EROFS_NO_KMAP, /* don't map the buffer */
204-
EROFS_KMAP, /* use kmap_local_page() to map the buffer */
205-
};
206-
207202
struct erofs_buf {
208203
struct address_space *mapping;
209204
struct file *file;
@@ -387,11 +382,10 @@ void *erofs_read_metadata(struct super_block *sb, struct erofs_buf *buf,
387382
erofs_off_t *offset, int *lengthp);
388383
void erofs_unmap_metabuf(struct erofs_buf *buf);
389384
void erofs_put_metabuf(struct erofs_buf *buf);
390-
void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset,
391-
enum erofs_kmap_type type);
385+
void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset, bool need_kmap);
392386
void erofs_init_metabuf(struct erofs_buf *buf, struct super_block *sb);
393387
void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb,
394-
erofs_off_t offset, enum erofs_kmap_type type);
388+
erofs_off_t offset, bool need_kmap);
395389
int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *dev);
396390
int erofs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
397391
u64 start, u64 len);

fs/erofs/namei.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static void *erofs_find_target_block(struct erofs_buf *target,
100100
struct erofs_dirent *de;
101101

102102
buf.mapping = dir->i_mapping;
103-
de = erofs_bread(&buf, erofs_pos(dir->i_sb, mid), EROFS_KMAP);
103+
de = erofs_bread(&buf, erofs_pos(dir->i_sb, mid), true);
104104
if (!IS_ERR(de)) {
105105
const int nameoff = nameoff_from_disk(de->nameoff, bsz);
106106
const int ndirents = nameoff / sizeof(*de);

fs/erofs/super.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void *erofs_read_metadata(struct super_block *sb, struct erofs_buf *buf,
9494
int len, i, cnt;
9595

9696
*offset = round_up(*offset, 4);
97-
ptr = erofs_bread(buf, *offset, EROFS_KMAP);
97+
ptr = erofs_bread(buf, *offset, true);
9898
if (IS_ERR(ptr))
9999
return ptr;
100100

@@ -110,7 +110,7 @@ void *erofs_read_metadata(struct super_block *sb, struct erofs_buf *buf,
110110
for (i = 0; i < len; i += cnt) {
111111
cnt = min_t(int, sb->s_blocksize - erofs_blkoff(sb, *offset),
112112
len - i);
113-
ptr = erofs_bread(buf, *offset, EROFS_KMAP);
113+
ptr = erofs_bread(buf, *offset, true);
114114
if (IS_ERR(ptr)) {
115115
kfree(buffer);
116116
return ptr;
@@ -141,7 +141,7 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb,
141141
struct erofs_deviceslot *dis;
142142
struct file *file;
143143

144-
dis = erofs_read_metabuf(buf, sb, *pos, EROFS_KMAP);
144+
dis = erofs_read_metabuf(buf, sb, *pos, true);
145145
if (IS_ERR(dis))
146146
return PTR_ERR(dis);
147147

@@ -255,7 +255,7 @@ static int erofs_read_superblock(struct super_block *sb)
255255
void *data;
256256
int ret;
257257

258-
data = erofs_read_metabuf(&buf, sb, 0, EROFS_KMAP);
258+
data = erofs_read_metabuf(&buf, sb, 0, true);
259259
if (IS_ERR(data)) {
260260
erofs_err(sb, "cannot read erofs superblock");
261261
return PTR_ERR(data);

fs/erofs/xattr.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static int erofs_init_inode_xattrs(struct inode *inode)
8181
it.pos = erofs_iloc(inode) + vi->inode_isize;
8282

8383
/* read in shared xattr array (non-atomic, see kmalloc below) */
84-
it.kaddr = erofs_bread(&it.buf, it.pos, EROFS_KMAP);
84+
it.kaddr = erofs_bread(&it.buf, it.pos, true);
8585
if (IS_ERR(it.kaddr)) {
8686
ret = PTR_ERR(it.kaddr);
8787
goto out_unlock;
@@ -102,7 +102,7 @@ static int erofs_init_inode_xattrs(struct inode *inode)
102102
it.pos += sizeof(struct erofs_xattr_ibody_header);
103103

104104
for (i = 0; i < vi->xattr_shared_count; ++i) {
105-
it.kaddr = erofs_bread(&it.buf, it.pos, EROFS_KMAP);
105+
it.kaddr = erofs_bread(&it.buf, it.pos, true);
106106
if (IS_ERR(it.kaddr)) {
107107
kfree(vi->xattr_shared_xattrs);
108108
vi->xattr_shared_xattrs = NULL;
@@ -183,7 +183,7 @@ static int erofs_xattr_copy_to_buffer(struct erofs_xattr_iter *it,
183183
void *src;
184184

185185
for (processed = 0; processed < len; processed += slice) {
186-
it->kaddr = erofs_bread(&it->buf, it->pos, EROFS_KMAP);
186+
it->kaddr = erofs_bread(&it->buf, it->pos, true);
187187
if (IS_ERR(it->kaddr))
188188
return PTR_ERR(it->kaddr);
189189

@@ -286,7 +286,7 @@ static int erofs_getxattr_foreach(struct erofs_xattr_iter *it)
286286

287287
/* 2. handle xattr name */
288288
for (processed = 0; processed < entry.e_name_len; processed += slice) {
289-
it->kaddr = erofs_bread(&it->buf, it->pos, EROFS_KMAP);
289+
it->kaddr = erofs_bread(&it->buf, it->pos, true);
290290
if (IS_ERR(it->kaddr))
291291
return PTR_ERR(it->kaddr);
292292

@@ -330,7 +330,7 @@ static int erofs_xattr_iter_inline(struct erofs_xattr_iter *it,
330330
it->pos = erofs_iloc(inode) + vi->inode_isize + xattr_header_sz;
331331

332332
while (remaining) {
333-
it->kaddr = erofs_bread(&it->buf, it->pos, EROFS_KMAP);
333+
it->kaddr = erofs_bread(&it->buf, it->pos, true);
334334
if (IS_ERR(it->kaddr))
335335
return PTR_ERR(it->kaddr);
336336

@@ -367,7 +367,7 @@ static int erofs_xattr_iter_shared(struct erofs_xattr_iter *it,
367367
for (i = 0; i < vi->xattr_shared_count; ++i) {
368368
it->pos = erofs_pos(sb, sbi->xattr_blkaddr) +
369369
vi->xattr_shared_xattrs[i] * sizeof(__le32);
370-
it->kaddr = erofs_bread(&it->buf, it->pos, EROFS_KMAP);
370+
it->kaddr = erofs_bread(&it->buf, it->pos, true);
371371
if (IS_ERR(it->kaddr))
372372
return PTR_ERR(it->kaddr);
373373

fs/erofs/zdata.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ static int z_erofs_pcluster_begin(struct z_erofs_frontend *fe)
832832
} else {
833833
void *mptr;
834834

835-
mptr = erofs_read_metabuf(&map->buf, sb, map->m_pa, EROFS_NO_KMAP);
835+
mptr = erofs_read_metabuf(&map->buf, sb, map->m_pa, false);
836836
if (IS_ERR(mptr)) {
837837
ret = PTR_ERR(mptr);
838838
erofs_err(sb, "failed to get inline data %d", ret);
@@ -967,7 +967,7 @@ static int z_erofs_read_fragment(struct super_block *sb, struct folio *folio,
967967
buf.mapping = packed_inode->i_mapping;
968968
for (; cur < end; cur += cnt, pos += cnt) {
969969
cnt = min(end - cur, sb->s_blocksize - erofs_blkoff(sb, pos));
970-
src = erofs_bread(&buf, pos, EROFS_KMAP);
970+
src = erofs_bread(&buf, pos, true);
971971
if (IS_ERR(src)) {
972972
erofs_put_metabuf(&buf);
973973
return PTR_ERR(src);

0 commit comments

Comments
 (0)