
From: Baokun Li <libaokun1@huawei.com> hulk inclusion category: bugfix bugzilla: 182993 https://gitee.com/openeuler/kernel/issues/I4DDEL --------------------------- If ubifs_garbage_collect_leb() returns -EAGAIN and ubifs_return_leb returns error, a LEB will always has a "taken" flag. In this case, set the ubifs to read-only to prevent a worse situation. Signed-off-by: Baokun Li <libaokun1@huawei.com> Reviewed-by: Zhang Yi <yi.zhang@huawei.com> Signed-off-by: Chen Jun <chenjun102@huawei.com> --- fs/ubifs/gc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c index 238a60294d10..e43c8161423d 100644 --- a/fs/ubifs/gc.c +++ b/fs/ubifs/gc.c @@ -756,8 +756,14 @@ int ubifs_garbage_collect(struct ubifs_info *c, int anyway) * caller instead of the original '-EAGAIN'. */ err = ubifs_return_leb(c, lp.lnum); - if (err) + if (err) { ret = err; + /* LEB may always be "taken". So set + * the ubifs to read-only. Sync wbuf + * will return -EROFS, then go "out". + */ + ubifs_ro_mode(c, ret); + } /* Maybe double return if go out */ lp.lnum = -1; break; -- 2.20.1