29b24f6ca112d drivers/staging/erofs/inode.c (Gao Xiang 2019-07-31 23:57:31 +0800 1) // SPDX-License-Identifier: GPL-2.0-only
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 2) /*
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 3) * Copyright (C) 2017-2018 HUAWEI, Inc.
592e7cd00bb9d fs/erofs/inode.c (Alexander A. Klimov 2020-07-13 15:09:44 +0200 4) * https://www.huawei.com/
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 5) * Created by Gao Xiang <gaoxiang25@huawei.com>
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 6) */
b17500a0fdbae drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:52 +0800 7) #include "xattr.h"
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 8)
13f06f48f7bf8 drivers/staging/erofs/inode.c (Chao Yu 2018-07-26 20:21:55 +0800 9) #include <trace/events/erofs.h>
13f06f48f7bf8 drivers/staging/erofs/inode.c (Chao Yu 2018-07-26 20:21:55 +0800 10)
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 11) /*
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 12) * if inode is successfully read, return its inode page (or sometimes
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 13) * the inode payload page if it's an extended inode) in order to fill
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 14) * inline data if possible.
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 15) */
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 16) static struct page *erofs_read_inode(struct inode *inode,
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 17) unsigned int *ofs)
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 18) {
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 19) struct super_block *sb = inode->i_sb;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 20) struct erofs_sb_info *sbi = EROFS_SB(sb);
a5876e24f13f1 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:56 +0800 21) struct erofs_inode *vi = EROFS_I(inode);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 22) const erofs_off_t inode_loc = iloc(sbi, vi->nid);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 23)
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 24) erofs_blk_t blkaddr, nblks = 0;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 25) struct page *page;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 26) struct erofs_inode_compact *dic;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 27) struct erofs_inode_extended *die, *copied = NULL;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 28) unsigned int ifmt;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 29) int err;
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 30)
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 31) blkaddr = erofs_blknr(inode_loc);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 32) *ofs = erofs_blkoff(inode_loc);
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 33)
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 34) erofs_dbg("%s, reading inode nid %llu at %u of blkaddr %u",
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 35) __func__, vi->nid, *ofs, blkaddr);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 36)
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 37) page = erofs_get_meta_page(sb, blkaddr);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 38) if (IS_ERR(page)) {
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 39) erofs_err(sb, "failed to get inode (nid: %llu) page, err %ld",
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 40) vi->nid, PTR_ERR(page));
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 41) return page;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 42) }
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 43)
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 44) dic = page_address(page) + *ofs;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 45) ifmt = le16_to_cpu(dic->i_format);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 46)
24a806d849c0b fs/erofs/inode.c (Gao Xiang 2021-03-29 08:36:14 +0800 47) if (ifmt & ~EROFS_I_ALL) {
24a806d849c0b fs/erofs/inode.c (Gao Xiang 2021-03-29 08:36:14 +0800 48) erofs_err(inode->i_sb, "unsupported i_format %u of nid %llu",
24a806d849c0b fs/erofs/inode.c (Gao Xiang 2021-03-29 08:36:14 +0800 49) ifmt, vi->nid);
24a806d849c0b fs/erofs/inode.c (Gao Xiang 2021-03-29 08:36:14 +0800 50) err = -EOPNOTSUPP;
24a806d849c0b fs/erofs/inode.c (Gao Xiang 2021-03-29 08:36:14 +0800 51) goto err_out;
24a806d849c0b fs/erofs/inode.c (Gao Xiang 2021-03-29 08:36:14 +0800 52) }
24a806d849c0b fs/erofs/inode.c (Gao Xiang 2021-03-29 08:36:14 +0800 53)
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 54) vi->datalayout = erofs_inode_datalayout(ifmt);
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 55) if (vi->datalayout >= EROFS_INODE_DATALAYOUT_MAX) {
4f761fa253b49 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:09 +0800 56) erofs_err(inode->i_sb, "unsupported datalayout %u of nid %llu",
4f761fa253b49 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:09 +0800 57) vi->datalayout, vi->nid);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 58) err = -EOPNOTSUPP;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 59) goto err_out;
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 60) }
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 61)
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 62) switch (erofs_inode_version(ifmt)) {
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 63) case EROFS_INODE_LAYOUT_EXTENDED:
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 64) vi->inode_isize = sizeof(struct erofs_inode_extended);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 65) /* check if the inode acrosses page boundary */
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 66) if (*ofs + vi->inode_isize <= PAGE_SIZE) {
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 67) *ofs += vi->inode_isize;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 68) die = (struct erofs_inode_extended *)dic;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 69) } else {
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 70) const unsigned int gotten = PAGE_SIZE - *ofs;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 71)
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 72) copied = kmalloc(vi->inode_isize, GFP_NOFS);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 73) if (!copied) {
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 74) err = -ENOMEM;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 75) goto err_out;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 76) }
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 77) memcpy(copied, dic, gotten);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 78) unlock_page(page);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 79) put_page(page);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 80)
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 81) page = erofs_get_meta_page(sb, blkaddr + 1);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 82) if (IS_ERR(page)) {
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 83) erofs_err(sb, "failed to get inode payload page (nid: %llu), err %ld",
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 84) vi->nid, PTR_ERR(page));
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 85) kfree(copied);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 86) return page;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 87) }
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 88) *ofs = vi->inode_isize - gotten;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 89) memcpy((u8 *)copied + gotten, page_address(page), *ofs);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 90) die = copied;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 91) }
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 92) vi->xattr_isize = erofs_xattr_ibody_size(die->i_xattr_icount);
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 93)
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 94) inode->i_mode = le16_to_cpu(die->i_mode);
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 95) switch (inode->i_mode & S_IFMT) {
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 96) case S_IFREG:
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 97) case S_IFDIR:
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 98) case S_IFLNK:
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 99) vi->raw_blkaddr = le32_to_cpu(die->i_u.raw_blkaddr);
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 100) break;
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 101) case S_IFCHR:
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 102) case S_IFBLK:
d5beb31b6b1c0 drivers/staging/erofs/inode.c (Chao Yu 2018-07-26 20:21:53 +0800 103) inode->i_rdev =
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 104) new_decode_dev(le32_to_cpu(die->i_u.rdev));
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 105) break;
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 106) case S_IFIFO:
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 107) case S_IFSOCK:
d5beb31b6b1c0 drivers/staging/erofs/inode.c (Chao Yu 2018-07-26 20:21:53 +0800 108) inode->i_rdev = 0;
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 109) break;
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 110) default:
a6b9b1d5eae61 drivers/staging/erofs/inode.c (Gao Xiang 2019-08-14 18:37:03 +0800 111) goto bogusimode;
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 112) }
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 113) i_uid_write(inode, le32_to_cpu(die->i_uid));
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 114) i_gid_write(inode, le32_to_cpu(die->i_gid));
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 115) set_nlink(inode, le32_to_cpu(die->i_nlink));
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 116)
d3938ee23e97b fs/erofs/inode.c (Gao Xiang 2020-11-01 03:51:02 +0800 117) /* extended inode has its own timestamp */
d3938ee23e97b fs/erofs/inode.c (Gao Xiang 2020-11-01 03:51:02 +0800 118) inode->i_ctime.tv_sec = le64_to_cpu(die->i_ctime);
d3938ee23e97b fs/erofs/inode.c (Gao Xiang 2020-11-01 03:51:02 +0800 119) inode->i_ctime.tv_nsec = le32_to_cpu(die->i_ctime_nsec);
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 120)
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 121) inode->i_size = le64_to_cpu(die->i_size);
fe6d98750cf04 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:43 +0800 122)
fe6d98750cf04 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:43 +0800 123) /* total blocks for compressed files */
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 124) if (erofs_inode_is_data_compressed(vi->datalayout))
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 125) nblks = le32_to_cpu(die->i_u.compressed_blocks);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 126)
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 127) kfree(copied);
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 128) break;
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 129) case EROFS_INODE_LAYOUT_COMPACT:
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 130) vi->inode_isize = sizeof(struct erofs_inode_compact);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 131) *ofs += vi->inode_isize;
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 132) vi->xattr_isize = erofs_xattr_ibody_size(dic->i_xattr_icount);
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 133)
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 134) inode->i_mode = le16_to_cpu(dic->i_mode);
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 135) switch (inode->i_mode & S_IFMT) {
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 136) case S_IFREG:
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 137) case S_IFDIR:
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 138) case S_IFLNK:
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 139) vi->raw_blkaddr = le32_to_cpu(dic->i_u.raw_blkaddr);
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 140) break;
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 141) case S_IFCHR:
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 142) case S_IFBLK:
d5beb31b6b1c0 drivers/staging/erofs/inode.c (Chao Yu 2018-07-26 20:21:53 +0800 143) inode->i_rdev =
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 144) new_decode_dev(le32_to_cpu(dic->i_u.rdev));
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 145) break;
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 146) case S_IFIFO:
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 147) case S_IFSOCK:
d5beb31b6b1c0 drivers/staging/erofs/inode.c (Chao Yu 2018-07-26 20:21:53 +0800 148) inode->i_rdev = 0;
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 149) break;
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 150) default:
a6b9b1d5eae61 drivers/staging/erofs/inode.c (Gao Xiang 2019-08-14 18:37:03 +0800 151) goto bogusimode;
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 152) }
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 153) i_uid_write(inode, le16_to_cpu(dic->i_uid));
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 154) i_gid_write(inode, le16_to_cpu(dic->i_gid));
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 155) set_nlink(inode, le16_to_cpu(dic->i_nlink));
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 156)
d3938ee23e97b fs/erofs/inode.c (Gao Xiang 2020-11-01 03:51:02 +0800 157) /* use build time for compact inodes */
d3938ee23e97b fs/erofs/inode.c (Gao Xiang 2020-11-01 03:51:02 +0800 158) inode->i_ctime.tv_sec = sbi->build_time;
d3938ee23e97b fs/erofs/inode.c (Gao Xiang 2020-11-01 03:51:02 +0800 159) inode->i_ctime.tv_nsec = sbi->build_time_nsec;
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 160)
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 161) inode->i_size = le32_to_cpu(dic->i_size);
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 162) if (erofs_inode_is_data_compressed(vi->datalayout))
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 163) nblks = le32_to_cpu(dic->i_u.compressed_blocks);
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 164) break;
8a76568225dea fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:54 +0800 165) default:
4f761fa253b49 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:09 +0800 166) erofs_err(inode->i_sb,
4f761fa253b49 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:09 +0800 167) "unsupported on-disk inode version %u of nid %llu",
4f761fa253b49 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:09 +0800 168) erofs_inode_version(ifmt), vi->nid);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 169) err = -EOPNOTSUPP;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 170) goto err_out;
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 171) }
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 172)
d3938ee23e97b fs/erofs/inode.c (Gao Xiang 2020-11-01 03:51:02 +0800 173) inode->i_mtime.tv_sec = inode->i_ctime.tv_sec;
d3938ee23e97b fs/erofs/inode.c (Gao Xiang 2020-11-01 03:51:02 +0800 174) inode->i_atime.tv_sec = inode->i_ctime.tv_sec;
d3938ee23e97b fs/erofs/inode.c (Gao Xiang 2020-11-01 03:51:02 +0800 175) inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec;
d3938ee23e97b fs/erofs/inode.c (Gao Xiang 2020-11-01 03:51:02 +0800 176) inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec;
d3938ee23e97b fs/erofs/inode.c (Gao Xiang 2020-11-01 03:51:02 +0800 177)
fe6d98750cf04 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:43 +0800 178) if (!nblks)
fe6d98750cf04 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:43 +0800 179) /* measure inode.i_blocks as generic filesystems */
fe6d98750cf04 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:43 +0800 180) inode->i_blocks = roundup(inode->i_size, EROFS_BLKSIZ) >> 9;
fe6d98750cf04 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:43 +0800 181) else
fe6d98750cf04 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:43 +0800 182) inode->i_blocks = nblks << LOG_SECTORS_PER_BLOCK;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 183) return page;
a6b9b1d5eae61 drivers/staging/erofs/inode.c (Gao Xiang 2019-08-14 18:37:03 +0800 184)
a6b9b1d5eae61 drivers/staging/erofs/inode.c (Gao Xiang 2019-08-14 18:37:03 +0800 185) bogusimode:
4f761fa253b49 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:09 +0800 186) erofs_err(inode->i_sb, "bogus i_mode (%o) @ nid %llu",
4f761fa253b49 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:09 +0800 187) inode->i_mode, vi->nid);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 188) err = -EFSCORRUPTED;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 189) err_out:
a6b9b1d5eae61 drivers/staging/erofs/inode.c (Gao Xiang 2019-08-14 18:37:03 +0800 190) DBG_BUGON(1);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 191) kfree(copied);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 192) unlock_page(page);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 193) put_page(page);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 194) return ERR_PTR(err);
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 195) }
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 196)
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 197) static int erofs_fill_symlink(struct inode *inode, void *data,
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 198) unsigned int m_pofs)
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 199) {
a5876e24f13f1 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:56 +0800 200) struct erofs_inode *vi = EROFS_I(inode);
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 201) char *lnk;
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 202)
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 203) /* if it cannot be handled with fast symlink scheme */
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 204) if (vi->datalayout != EROFS_INODE_FLAT_INLINE ||
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 205) inode->i_size >= PAGE_SIZE) {
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 206) inode->i_op = &erofs_symlink_iops;
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 207) return 0;
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 208) }
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 209)
e2c71e74b21e4 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:06 +0800 210) lnk = kmalloc(inode->i_size + 1, GFP_KERNEL);
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 211) if (!lnk)
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 212) return -ENOMEM;
8b987bca2d096 drivers/staging/erofs/inode.c (Gao Xiang 2018-12-05 21:23:13 +0800 213)
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 214) m_pofs += vi->xattr_isize;
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 215) /* inline symlink data shouldn't cross page boundary as well */
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 216) if (m_pofs + inode->i_size > PAGE_SIZE) {
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 217) kfree(lnk);
4f761fa253b49 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:09 +0800 218) erofs_err(inode->i_sb,
4f761fa253b49 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:09 +0800 219) "inline data cross block boundary @ nid %llu",
4f761fa253b49 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:09 +0800 220) vi->nid);
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 221) DBG_BUGON(1);
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 222) return -EFSCORRUPTED;
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 223) }
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 224)
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 225) memcpy(lnk, data + m_pofs, inode->i_size);
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 226) lnk[inode->i_size] = '\0';
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 227)
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 228) inode->i_link = lnk;
a2c75c8143eaa fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:59 +0800 229) inode->i_op = &erofs_fast_symlink_iops;
5545745930ea4 drivers/staging/erofs/inode.c (Yue Hu 2019-06-27 17:46:15 +0800 230) return 0;
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 231) }
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 232)
99634bf388db0 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:05 +0800 233) static int erofs_fill_inode(struct inode *inode, int isdir)
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 234) {
a5876e24f13f1 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:56 +0800 235) struct erofs_inode *vi = EROFS_I(inode);
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 236) struct page *page;
7dd68b147d60e drivers/staging/erofs/inode.c (Thomas Weißschuh 2018-09-10 21:41:14 +0200 237) unsigned int ofs;
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 238) int err = 0;
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 239)
13f06f48f7bf8 drivers/staging/erofs/inode.c (Chao Yu 2018-07-26 20:21:55 +0800 240) trace_erofs_fill_inode(inode, isdir);
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 241)
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 242) /* read inode base data from disk */
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 243) page = erofs_read_inode(inode, &ofs);
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 244) if (IS_ERR(page))
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 245) return PTR_ERR(page);
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 246)
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 247) /* setup the new inode */
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 248) switch (inode->i_mode & S_IFMT) {
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 249) case S_IFREG:
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 250) inode->i_op = &erofs_generic_iops;
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 251) inode->i_fop = &generic_ro_fops;
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 252) break;
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 253) case S_IFDIR:
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 254) inode->i_op = &erofs_dir_iops;
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 255) inode->i_fop = &erofs_dir_fops;
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 256) break;
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 257) case S_IFLNK:
0dcd3c94e0243 fs/erofs/inode.c (Gao Xiang 2020-07-30 01:58:01 +0800 258) err = erofs_fill_symlink(inode, page_address(page), ofs);
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 259) if (err)
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 260) goto out_unlock;
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 261) inode_nohighmem(inode);
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 262) break;
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 263) case S_IFCHR:
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 264) case S_IFBLK:
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 265) case S_IFIFO:
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 266) case S_IFSOCK:
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 267) inode->i_op = &erofs_generic_iops;
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 268) init_special_inode(inode, inode->i_mode, inode->i_rdev);
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 269) goto out_unlock;
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 270) default:
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 271) err = -EFSCORRUPTED;
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 272) goto out_unlock;
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 273) }
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 274)
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 275) if (erofs_inode_is_data_compressed(vi->datalayout)) {
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 276) err = z_erofs_fill_inode(inode);
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 277) goto out_unlock;
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 278) }
84947eb603719 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:08 +0800 279) inode->i_mapping->a_ops = &erofs_raw_access_aops;
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 280)
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 281) out_unlock:
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 282) unlock_page(page);
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 283) put_page(page);
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 284) return err;
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 285) }
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 286)
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 287) /*
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 288) * erofs nid is 64bits, but i_ino is 'unsigned long', therefore
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 289) * we should do more for 32-bit platform to find the right inode.
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 290) */
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 291) static int erofs_ilookup_test_actor(struct inode *inode, void *opaque)
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 292) {
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 293) const erofs_nid_t nid = *(erofs_nid_t *)opaque;
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 294)
a5876e24f13f1 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:56 +0800 295) return EROFS_I(inode)->nid == nid;
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 296) }
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 297)
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 298) static int erofs_iget_set_actor(struct inode *inode, void *opaque)
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 299) {
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 300) const erofs_nid_t nid = *(erofs_nid_t *)opaque;
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 301)
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 302) inode->i_ino = erofs_inode_hash(nid);
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 303) return 0;
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 304) }
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 305)
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 306) static inline struct inode *erofs_iget_locked(struct super_block *sb,
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 307) erofs_nid_t nid)
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 308) {
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 309) const unsigned long hashval = erofs_inode_hash(nid);
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 310)
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 311) return iget5_locked(sb, hashval, erofs_ilookup_test_actor,
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 312) erofs_iget_set_actor, &nid);
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 313) }
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 314)
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 315) struct inode *erofs_iget(struct super_block *sb,
447a3621b3835 drivers/staging/erofs/inode.c (Julian Merida 2019-03-18 20:58:41 -0300 316) erofs_nid_t nid,
447a3621b3835 drivers/staging/erofs/inode.c (Julian Merida 2019-03-18 20:58:41 -0300 317) bool isdir)
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 318) {
2abd781413877 drivers/staging/erofs/inode.c (Gao Xiang 2018-10-09 22:07:13 +0800 319) struct inode *inode = erofs_iget_locked(sb, nid);
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 320)
8d8a09b093d70 fs/erofs/inode.c (Gao Xiang 2019-08-30 00:38:27 +0800 321) if (!inode)
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 322) return ERR_PTR(-ENOMEM);
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 323)
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 324) if (inode->i_state & I_NEW) {
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 325) int err;
a5876e24f13f1 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:56 +0800 326) struct erofs_inode *vi = EROFS_I(inode);
8af36478f9516 drivers/staging/erofs/inode.c (Julio Bianco 2019-03-09 14:08:53 -0300 327)
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 328) vi->nid = nid;
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 329)
99634bf388db0 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:09:05 +0800 330) err = erofs_fill_inode(inode, isdir);
8d8a09b093d70 fs/erofs/inode.c (Gao Xiang 2019-08-30 00:38:27 +0800 331) if (!err)
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 332) unlock_new_inode(inode);
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 333) else {
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 334) iget_failed(inode);
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 335) inode = ERR_PTR(err);
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 336) }
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 337) }
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 338) return inode;
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 339) }
431339ba90423 drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:48 +0800 340)
549c7297717c3 fs/erofs/inode.c (Christian Brauner 2021-01-21 14:19:43 +0100 341) int erofs_getattr(struct user_namespace *mnt_userns, const struct path *path,
549c7297717c3 fs/erofs/inode.c (Christian Brauner 2021-01-21 14:19:43 +0100 342) struct kstat *stat, u32 request_mask,
549c7297717c3 fs/erofs/inode.c (Christian Brauner 2021-01-21 14:19:43 +0100 343) unsigned int query_flags)
89f27eded5b63 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:42 +0800 344) {
89f27eded5b63 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:42 +0800 345) struct inode *const inode = d_inode(path->dentry);
89f27eded5b63 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:42 +0800 346)
a5876e24f13f1 fs/erofs/inode.c (Gao Xiang 2019-09-04 10:08:56 +0800 347) if (erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout))
89f27eded5b63 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:42 +0800 348) stat->attributes |= STATX_ATTR_COMPRESSED;
89f27eded5b63 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:42 +0800 349)
89f27eded5b63 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:42 +0800 350) stat->attributes |= STATX_ATTR_IMMUTABLE;
89f27eded5b63 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:42 +0800 351) stat->attributes_mask |= (STATX_ATTR_COMPRESSED |
89f27eded5b63 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:42 +0800 352) STATX_ATTR_IMMUTABLE);
89f27eded5b63 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:42 +0800 353)
0d56a4518d5ea fs/erofs/inode.c (Christian Brauner 2021-01-21 14:19:30 +0100 354) generic_fillattr(&init_user_ns, inode, stat);
89f27eded5b63 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:42 +0800 355) return 0;
89f27eded5b63 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:42 +0800 356) }
89f27eded5b63 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:42 +0800 357)
609398266c542 drivers/staging/erofs/inode.c (Gao Xiang 2019-01-14 19:40:24 +0800 358) const struct inode_operations erofs_generic_iops = {
89f27eded5b63 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:42 +0800 359) .getattr = erofs_getattr,
b17500a0fdbae drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:52 +0800 360) .listxattr = erofs_listxattr,
516c115c9170f drivers/staging/erofs/inode.c (Gao Xiang 2019-01-29 16:35:20 +0800 361) .get_acl = erofs_get_acl,
b17500a0fdbae drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:52 +0800 362) };
b17500a0fdbae drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:52 +0800 363)
609398266c542 drivers/staging/erofs/inode.c (Gao Xiang 2019-01-14 19:40:24 +0800 364) const struct inode_operations erofs_symlink_iops = {
b17500a0fdbae drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:52 +0800 365) .get_link = page_get_link,
89f27eded5b63 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:42 +0800 366) .getattr = erofs_getattr,
b17500a0fdbae drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:52 +0800 367) .listxattr = erofs_listxattr,
516c115c9170f drivers/staging/erofs/inode.c (Gao Xiang 2019-01-29 16:35:20 +0800 368) .get_acl = erofs_get_acl,
b17500a0fdbae drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:52 +0800 369) };
b17500a0fdbae drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:52 +0800 370)
609398266c542 drivers/staging/erofs/inode.c (Gao Xiang 2019-01-14 19:40:24 +0800 371) const struct inode_operations erofs_fast_symlink_iops = {
b17500a0fdbae drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:52 +0800 372) .get_link = simple_get_link,
89f27eded5b63 drivers/staging/erofs/inode.c (Gao Xiang 2019-05-28 11:19:42 +0800 373) .getattr = erofs_getattr,
b17500a0fdbae drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:52 +0800 374) .listxattr = erofs_listxattr,
516c115c9170f drivers/staging/erofs/inode.c (Gao Xiang 2019-01-29 16:35:20 +0800 375) .get_acl = erofs_get_acl,
609398266c542 drivers/staging/erofs/inode.c (Gao Xiang 2019-01-14 19:40:24 +0800 376) };
b17500a0fdbae drivers/staging/erofs/inode.c (Gao Xiang 2018-07-26 20:21:52 +0800 377)