Skip to content

Commit 9a05c6a

Browse files
committed
erofs: drop z_erofs_page_mark_eio()
It can be folded into z_erofs_onlinepage_endio() to simplify the code. Reviewed-by: Yue Hu <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e4c1cf5 commit 9a05c6a

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

fs/erofs/zdata.c

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -143,22 +143,17 @@ static inline void z_erofs_onlinepage_split(struct page *page)
143143
atomic_inc((atomic_t *)&page->private);
144144
}
145145

146-
static inline void z_erofs_page_mark_eio(struct page *page)
146+
static void z_erofs_onlinepage_endio(struct page *page, int err)
147147
{
148-
int orig;
148+
int orig, v;
149+
150+
DBG_BUGON(!PagePrivate(page));
149151

150152
do {
151153
orig = atomic_read((atomic_t *)&page->private);
152-
} while (atomic_cmpxchg((atomic_t *)&page->private, orig,
153-
orig | Z_EROFS_PAGE_EIO) != orig);
154-
}
155-
156-
static inline void z_erofs_onlinepage_endio(struct page *page)
157-
{
158-
unsigned int v;
154+
v = (orig - 1) | (err ? Z_EROFS_PAGE_EIO : 0);
155+
} while (atomic_cmpxchg((atomic_t *)&page->private, orig, v) != orig);
159156

160-
DBG_BUGON(!PagePrivate(page));
161-
v = atomic_dec_return((atomic_t *)&page->private);
162157
if (!(v & ~Z_EROFS_PAGE_EIO)) {
163158
set_page_private(page, 0);
164159
ClearPagePrivate(page);
@@ -1067,9 +1062,7 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
10671062
goto repeat;
10681063

10691064
out:
1070-
if (err)
1071-
z_erofs_page_mark_eio(page);
1072-
z_erofs_onlinepage_endio(page);
1065+
z_erofs_onlinepage_endio(page, err);
10731066
return err;
10741067
}
10751068

@@ -1172,9 +1165,7 @@ static void z_erofs_fill_other_copies(struct z_erofs_decompress_backend *be,
11721165
cur += len;
11731166
}
11741167
kunmap_local(dst);
1175-
if (err)
1176-
z_erofs_page_mark_eio(bvi->bvec.page);
1177-
z_erofs_onlinepage_endio(bvi->bvec.page);
1168+
z_erofs_onlinepage_endio(bvi->bvec.page, err);
11781169
list_del(p);
11791170
kfree(bvi);
11801171
}
@@ -1345,9 +1336,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
13451336
/* recycle all individual short-lived pages */
13461337
if (z_erofs_put_shortlivedpage(be->pagepool, page))
13471338
continue;
1348-
if (err)
1349-
z_erofs_page_mark_eio(page);
1350-
z_erofs_onlinepage_endio(page);
1339+
z_erofs_onlinepage_endio(page, err);
13511340
}
13521341

13531342
if (be->decompressed_pages != be->onstack_pages)

0 commit comments

Comments
 (0)