Commit 019c407c authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'erofs-for-5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs

Pull erofs updates from Gao Xiang:
 "This cycle mainly addresses an issue out of some extended inode with
  designated location, which are not generated by current mkfs but need
  to handled at runtime anyway. The others are quite trivial ones.

   - use HTTPS links instead of insecure HTTP ones;

   - fix crossing page boundary on specific extended inodes;

   - remove useless WQ_CPU_INTENSIVE flag for unbound wq;

   - minor cleanup"

* tag 'erofs-for-5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs:
  erofs: remove WQ_CPU_INTENSIVE flag from unbound wq's
  erofs: fold in used-once helper erofs_workgroup_unfreeze_final()
  erofs: fix extended inode could cross boundary
  erofs: Replace HTTP links with HTTPS ones
parents 327a8d76 0e62ea33
/* SPDX-License-Identifier: GPL-2.0-only */ /* SPDX-License-Identifier: GPL-2.0-only */
/* /*
* Copyright (C) 2019 HUAWEI, Inc. * Copyright (C) 2019 HUAWEI, Inc.
* http://www.huawei.com/ * https://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com> * Created by Gao Xiang <gaoxiang25@huawei.com>
*/ */
#ifndef __EROFS_FS_COMPRESS_H #ifndef __EROFS_FS_COMPRESS_H
......
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (C) 2017-2018 HUAWEI, Inc. * Copyright (C) 2017-2018 HUAWEI, Inc.
* http://www.huawei.com/ * https://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com> * Created by Gao Xiang <gaoxiang25@huawei.com>
*/ */
#include "internal.h" #include "internal.h"
......
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (C) 2019 HUAWEI, Inc. * Copyright (C) 2019 HUAWEI, Inc.
* http://www.huawei.com/ * https://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com> * Created by Gao Xiang <gaoxiang25@huawei.com>
*/ */
#include "compress.h" #include "compress.h"
......
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (C) 2017-2018 HUAWEI, Inc. * Copyright (C) 2017-2018 HUAWEI, Inc.
* http://www.huawei.com/ * https://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com> * Created by Gao Xiang <gaoxiang25@huawei.com>
*/ */
#include "internal.h" #include "internal.h"
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* EROFS (Enhanced ROM File System) on-disk format definition * EROFS (Enhanced ROM File System) on-disk format definition
* *
* Copyright (C) 2017-2018 HUAWEI, Inc. * Copyright (C) 2017-2018 HUAWEI, Inc.
* http://www.huawei.com/ * https://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com> * Created by Gao Xiang <gaoxiang25@huawei.com>
*/ */
#ifndef __EROFS_FS_H #ifndef __EROFS_FS_H
......
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (C) 2017-2018 HUAWEI, Inc. * Copyright (C) 2017-2018 HUAWEI, Inc.
* http://www.huawei.com/ * https://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com> * Created by Gao Xiang <gaoxiang25@huawei.com>
*/ */
#include "xattr.h" #include "xattr.h"
#include <trace/events/erofs.h> #include <trace/events/erofs.h>
/* no locking */ /*
static int erofs_read_inode(struct inode *inode, void *data) * if inode is successfully read, return its inode page (or sometimes
* the inode payload page if it's an extended inode) in order to fill
* inline data if possible.
*/
static struct page *erofs_read_inode(struct inode *inode,
unsigned int *ofs)
{ {
struct super_block *sb = inode->i_sb;
struct erofs_sb_info *sbi = EROFS_SB(sb);
struct erofs_inode *vi = EROFS_I(inode); struct erofs_inode *vi = EROFS_I(inode);
struct erofs_inode_compact *dic = data; const erofs_off_t inode_loc = iloc(sbi, vi->nid);
struct erofs_inode_extended *die;
const unsigned int ifmt = le16_to_cpu(dic->i_format); erofs_blk_t blkaddr, nblks = 0;
struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb); struct page *page;
erofs_blk_t nblks = 0; struct erofs_inode_compact *dic;
struct erofs_inode_extended *die, *copied = NULL;
unsigned int ifmt;
int err;
vi->datalayout = erofs_inode_datalayout(ifmt); blkaddr = erofs_blknr(inode_loc);
*ofs = erofs_blkoff(inode_loc);
erofs_dbg("%s, reading inode nid %llu at %u of blkaddr %u",
__func__, vi->nid, *ofs, blkaddr);
page = erofs_get_meta_page(sb, blkaddr);
if (IS_ERR(page)) {
erofs_err(sb, "failed to get inode (nid: %llu) page, err %ld",
vi->nid, PTR_ERR(page));
return page;
}
dic = page_address(page) + *ofs;
ifmt = le16_to_cpu(dic->i_format);
vi->datalayout = erofs_inode_datalayout(ifmt);
if (vi->datalayout >= EROFS_INODE_DATALAYOUT_MAX) { if (vi->datalayout >= EROFS_INODE_DATALAYOUT_MAX) {
erofs_err(inode->i_sb, "unsupported datalayout %u of nid %llu", erofs_err(inode->i_sb, "unsupported datalayout %u of nid %llu",
vi->datalayout, vi->nid); vi->datalayout, vi->nid);
DBG_BUGON(1); err = -EOPNOTSUPP;
return -EOPNOTSUPP; goto err_out;
} }
switch (erofs_inode_version(ifmt)) { switch (erofs_inode_version(ifmt)) {
case EROFS_INODE_LAYOUT_EXTENDED: case EROFS_INODE_LAYOUT_EXTENDED:
die = data;
vi->inode_isize = sizeof(struct erofs_inode_extended); vi->inode_isize = sizeof(struct erofs_inode_extended);
/* check if the inode acrosses page boundary */
if (*ofs + vi->inode_isize <= PAGE_SIZE) {
*ofs += vi->inode_isize;
die = (struct erofs_inode_extended *)dic;
} else {
const unsigned int gotten = PAGE_SIZE - *ofs;
copied = kmalloc(vi->inode_isize, GFP_NOFS);
if (!copied) {
err = -ENOMEM;
goto err_out;
}
memcpy(copied, dic, gotten);
unlock_page(page);
put_page(page);
page = erofs_get_meta_page(sb, blkaddr + 1);
if (IS_ERR(page)) {
erofs_err(sb, "failed to get inode payload page (nid: %llu), err %ld",
vi->nid, PTR_ERR(page));
kfree(copied);
return page;
}
*ofs = vi->inode_isize - gotten;
memcpy((u8 *)copied + gotten, page_address(page), *ofs);
die = copied;
}
vi->xattr_isize = erofs_xattr_ibody_size(die->i_xattr_icount); vi->xattr_isize = erofs_xattr_ibody_size(die->i_xattr_icount);
inode->i_mode = le16_to_cpu(die->i_mode); inode->i_mode = le16_to_cpu(die->i_mode);
...@@ -69,9 +118,12 @@ static int erofs_read_inode(struct inode *inode, void *data) ...@@ -69,9 +118,12 @@ static int erofs_read_inode(struct inode *inode, void *data)
/* total blocks for compressed files */ /* total blocks for compressed files */
if (erofs_inode_is_data_compressed(vi->datalayout)) if (erofs_inode_is_data_compressed(vi->datalayout))
nblks = le32_to_cpu(die->i_u.compressed_blocks); nblks = le32_to_cpu(die->i_u.compressed_blocks);
kfree(copied);
break; break;
case EROFS_INODE_LAYOUT_COMPACT: case EROFS_INODE_LAYOUT_COMPACT:
vi->inode_isize = sizeof(struct erofs_inode_compact); vi->inode_isize = sizeof(struct erofs_inode_compact);
*ofs += vi->inode_isize;
vi->xattr_isize = erofs_xattr_ibody_size(dic->i_xattr_icount); vi->xattr_isize = erofs_xattr_ibody_size(dic->i_xattr_icount);
inode->i_mode = le16_to_cpu(dic->i_mode); inode->i_mode = le16_to_cpu(dic->i_mode);
...@@ -111,8 +163,8 @@ static int erofs_read_inode(struct inode *inode, void *data) ...@@ -111,8 +163,8 @@ static int erofs_read_inode(struct inode *inode, void *data)
erofs_err(inode->i_sb, erofs_err(inode->i_sb,
"unsupported on-disk inode version %u of nid %llu", "unsupported on-disk inode version %u of nid %llu",
erofs_inode_version(ifmt), vi->nid); erofs_inode_version(ifmt), vi->nid);
DBG_BUGON(1); err = -EOPNOTSUPP;
return -EOPNOTSUPP; goto err_out;
} }
if (!nblks) if (!nblks)
...@@ -120,13 +172,18 @@ static int erofs_read_inode(struct inode *inode, void *data) ...@@ -120,13 +172,18 @@ static int erofs_read_inode(struct inode *inode, void *data)
inode->i_blocks = roundup(inode->i_size, EROFS_BLKSIZ) >> 9; inode->i_blocks = roundup(inode->i_size, EROFS_BLKSIZ) >> 9;
else else
inode->i_blocks = nblks << LOG_SECTORS_PER_BLOCK; inode->i_blocks = nblks << LOG_SECTORS_PER_BLOCK;
return 0; return page;
bogusimode: bogusimode:
erofs_err(inode->i_sb, "bogus i_mode (%o) @ nid %llu", erofs_err(inode->i_sb, "bogus i_mode (%o) @ nid %llu",
inode->i_mode, vi->nid); inode->i_mode, vi->nid);
err = -EFSCORRUPTED;
err_out:
DBG_BUGON(1); DBG_BUGON(1);
return -EFSCORRUPTED; kfree(copied);
unlock_page(page);
put_page(page);
return ERR_PTR(err);
} }
static int erofs_fill_symlink(struct inode *inode, void *data, static int erofs_fill_symlink(struct inode *inode, void *data,
...@@ -146,7 +203,7 @@ static int erofs_fill_symlink(struct inode *inode, void *data, ...@@ -146,7 +203,7 @@ static int erofs_fill_symlink(struct inode *inode, void *data,
if (!lnk) if (!lnk)
return -ENOMEM; return -ENOMEM;
m_pofs += vi->inode_isize + vi->xattr_isize; m_pofs += vi->xattr_isize;
/* inline symlink data shouldn't cross page boundary as well */ /* inline symlink data shouldn't cross page boundary as well */
if (m_pofs + inode->i_size > PAGE_SIZE) { if (m_pofs + inode->i_size > PAGE_SIZE) {
kfree(lnk); kfree(lnk);
...@@ -167,37 +224,17 @@ static int erofs_fill_symlink(struct inode *inode, void *data, ...@@ -167,37 +224,17 @@ static int erofs_fill_symlink(struct inode *inode, void *data,
static int erofs_fill_inode(struct inode *inode, int isdir) static int erofs_fill_inode(struct inode *inode, int isdir)
{ {
struct super_block *sb = inode->i_sb;
struct erofs_inode *vi = EROFS_I(inode); struct erofs_inode *vi = EROFS_I(inode);
struct page *page; struct page *page;
void *data;
int err;
erofs_blk_t blkaddr;
unsigned int ofs; unsigned int ofs;
erofs_off_t inode_loc; int err = 0;
trace_erofs_fill_inode(inode, isdir); trace_erofs_fill_inode(inode, isdir);
inode_loc = iloc(EROFS_SB(sb), vi->nid);
blkaddr = erofs_blknr(inode_loc);
ofs = erofs_blkoff(inode_loc);
erofs_dbg("%s, reading inode nid %llu at %u of blkaddr %u", /* read inode base data from disk */
__func__, vi->nid, ofs, blkaddr); page = erofs_read_inode(inode, &ofs);
if (IS_ERR(page))
page = erofs_get_meta_page(sb, blkaddr);
if (IS_ERR(page)) {
erofs_err(sb, "failed to get inode (nid: %llu) page, err %ld",
vi->nid, PTR_ERR(page));
return PTR_ERR(page); return PTR_ERR(page);
}
DBG_BUGON(!PageUptodate(page));
data = page_address(page);
err = erofs_read_inode(inode, data + ofs);
if (err)
goto out_unlock;
/* setup the new inode */ /* setup the new inode */
switch (inode->i_mode & S_IFMT) { switch (inode->i_mode & S_IFMT) {
...@@ -210,7 +247,7 @@ static int erofs_fill_inode(struct inode *inode, int isdir) ...@@ -210,7 +247,7 @@ static int erofs_fill_inode(struct inode *inode, int isdir)
inode->i_fop = &erofs_dir_fops; inode->i_fop = &erofs_dir_fops;
break; break;
case S_IFLNK: case S_IFLNK:
err = erofs_fill_symlink(inode, data, ofs); err = erofs_fill_symlink(inode, page_address(page), ofs);
if (err) if (err)
goto out_unlock; goto out_unlock;
inode_nohighmem(inode); inode_nohighmem(inode);
......
/* SPDX-License-Identifier: GPL-2.0-only */ /* SPDX-License-Identifier: GPL-2.0-only */
/* /*
* Copyright (C) 2017-2018 HUAWEI, Inc. * Copyright (C) 2017-2018 HUAWEI, Inc.
* http://www.huawei.com/ * https://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com> * Created by Gao Xiang <gaoxiang25@huawei.com>
*/ */
#ifndef __EROFS_INTERNAL_H #ifndef __EROFS_INTERNAL_H
......
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (C) 2017-2018 HUAWEI, Inc. * Copyright (C) 2017-2018 HUAWEI, Inc.
* http://www.huawei.com/ * https://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com> * Created by Gao Xiang <gaoxiang25@huawei.com>
*/ */
#include "xattr.h" #include "xattr.h"
......
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (C) 2017-2018 HUAWEI, Inc. * Copyright (C) 2017-2018 HUAWEI, Inc.
* http://www.huawei.com/ * https://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com> * Created by Gao Xiang <gaoxiang25@huawei.com>
*/ */
#include <linux/module.h> #include <linux/module.h>
......
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (C) 2018 HUAWEI, Inc. * Copyright (C) 2018 HUAWEI, Inc.
* http://www.huawei.com/ * https://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com> * Created by Gao Xiang <gaoxiang25@huawei.com>
*/ */
#include "internal.h" #include "internal.h"
...@@ -127,12 +127,6 @@ int erofs_workgroup_put(struct erofs_workgroup *grp) ...@@ -127,12 +127,6 @@ int erofs_workgroup_put(struct erofs_workgroup *grp)
return count; return count;
} }
static void erofs_workgroup_unfreeze_final(struct erofs_workgroup *grp)
{
erofs_workgroup_unfreeze(grp, 0);
__erofs_workgroup_free(grp);
}
static bool erofs_try_to_release_workgroup(struct erofs_sb_info *sbi, static bool erofs_try_to_release_workgroup(struct erofs_sb_info *sbi,
struct erofs_workgroup *grp) struct erofs_workgroup *grp)
{ {
...@@ -162,11 +156,9 @@ static bool erofs_try_to_release_workgroup(struct erofs_sb_info *sbi, ...@@ -162,11 +156,9 @@ static bool erofs_try_to_release_workgroup(struct erofs_sb_info *sbi,
*/ */
DBG_BUGON(xa_erase(&sbi->managed_pslots, grp->index) != grp); DBG_BUGON(xa_erase(&sbi->managed_pslots, grp->index) != grp);
/* /* last refcount should be connected with its managed pslot. */
* If managed cache is on, last refcount should indicate erofs_workgroup_unfreeze(grp, 0);
* the related workstation. __erofs_workgroup_free(grp);
*/
erofs_workgroup_unfreeze_final(grp);
return true; return true;
} }
......
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (C) 2017-2018 HUAWEI, Inc. * Copyright (C) 2017-2018 HUAWEI, Inc.
* http://www.huawei.com/ * https://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com> * Created by Gao Xiang <gaoxiang25@huawei.com>
*/ */
#include <linux/security.h> #include <linux/security.h>
......
/* SPDX-License-Identifier: GPL-2.0-only */ /* SPDX-License-Identifier: GPL-2.0-only */
/* /*
* Copyright (C) 2017-2018 HUAWEI, Inc. * Copyright (C) 2017-2018 HUAWEI, Inc.
* http://www.huawei.com/ * https://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com> * Created by Gao Xiang <gaoxiang25@huawei.com>
*/ */
#ifndef __EROFS_XATTR_H #ifndef __EROFS_XATTR_H
......
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (C) 2018 HUAWEI, Inc. * Copyright (C) 2018 HUAWEI, Inc.
* http://www.huawei.com/ * https://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com> * Created by Gao Xiang <gaoxiang25@huawei.com>
*/ */
#include "zdata.h" #include "zdata.h"
...@@ -43,13 +43,13 @@ void z_erofs_exit_zip_subsystem(void) ...@@ -43,13 +43,13 @@ void z_erofs_exit_zip_subsystem(void)
static inline int z_erofs_init_workqueue(void) static inline int z_erofs_init_workqueue(void)
{ {
const unsigned int onlinecpus = num_possible_cpus(); const unsigned int onlinecpus = num_possible_cpus();
const unsigned int flags = WQ_UNBOUND | WQ_HIGHPRI | WQ_CPU_INTENSIVE;
/* /*
* no need to spawn too many threads, limiting threads could minimum * no need to spawn too many threads, limiting threads could minimum
* scheduling overhead, perhaps per-CPU threads should be better? * scheduling overhead, perhaps per-CPU threads should be better?
*/ */
z_erofs_workqueue = alloc_workqueue("erofs_unzipd", flags, z_erofs_workqueue = alloc_workqueue("erofs_unzipd",
WQ_UNBOUND | WQ_HIGHPRI,
onlinecpus + onlinecpus / 4); onlinecpus + onlinecpus / 4);
return z_erofs_workqueue ? 0 : -ENOMEM; return z_erofs_workqueue ? 0 : -ENOMEM;
} }
......
/* SPDX-License-Identifier: GPL-2.0-only */ /* SPDX-License-Identifier: GPL-2.0-only */
/* /*
* Copyright (C) 2018 HUAWEI, Inc. * Copyright (C) 2018 HUAWEI, Inc.
* http://www.huawei.com/ * https://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com> * Created by Gao Xiang <gaoxiang25@huawei.com>
*/ */
#ifndef __EROFS_FS_ZDATA_H #ifndef __EROFS_FS_ZDATA_H
......
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (C) 2018-2019 HUAWEI, Inc. * Copyright (C) 2018-2019 HUAWEI, Inc.
* http://www.huawei.com/ * https://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com> * Created by Gao Xiang <gaoxiang25@huawei.com>
*/ */
#include "internal.h" #include "internal.h"
......
/* SPDX-License-Identifier: GPL-2.0-only */ /* SPDX-License-Identifier: GPL-2.0-only */
/* /*
* Copyright (C) 2018 HUAWEI, Inc. * Copyright (C) 2018 HUAWEI, Inc.
* http://www.huawei.com/ * https://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com> * Created by Gao Xiang <gaoxiang25@huawei.com>
*/ */
#ifndef __EROFS_FS_ZPVEC_H #ifndef __EROFS_FS_ZPVEC_H
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment