Lines Matching +full:on +full:- +full:die

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2017-2018 HUAWEI, Inc.
19 struct super_block *sb = inode->i_sb; in erofs_read_inode()
22 const erofs_off_t inode_loc = iloc(sbi, vi->nid); in erofs_read_inode()
27 struct erofs_inode_extended *die, *copied = NULL; in erofs_read_inode() local
35 __func__, vi->nid, *ofs, blkaddr); in erofs_read_inode()
40 vi->nid, PTR_ERR(page)); in erofs_read_inode()
45 ifmt = le16_to_cpu(dic->i_format); in erofs_read_inode()
48 erofs_err(inode->i_sb, "unsupported i_format %u of nid %llu", in erofs_read_inode()
49 ifmt, vi->nid); in erofs_read_inode()
50 err = -EOPNOTSUPP; in erofs_read_inode()
54 vi->datalayout = erofs_inode_datalayout(ifmt); in erofs_read_inode()
55 if (vi->datalayout >= EROFS_INODE_DATALAYOUT_MAX) { in erofs_read_inode()
56 erofs_err(inode->i_sb, "unsupported datalayout %u of nid %llu", in erofs_read_inode()
57 vi->datalayout, vi->nid); in erofs_read_inode()
58 err = -EOPNOTSUPP; in erofs_read_inode()
64 vi->inode_isize = sizeof(struct erofs_inode_extended); in erofs_read_inode()
66 if (*ofs + vi->inode_isize <= PAGE_SIZE) { in erofs_read_inode()
67 *ofs += vi->inode_isize; in erofs_read_inode()
68 die = (struct erofs_inode_extended *)dic; in erofs_read_inode()
70 const unsigned int gotten = PAGE_SIZE - *ofs; in erofs_read_inode()
72 copied = kmalloc(vi->inode_isize, GFP_NOFS); in erofs_read_inode()
74 err = -ENOMEM; in erofs_read_inode()
84 vi->nid, PTR_ERR(page)); in erofs_read_inode()
88 *ofs = vi->inode_isize - gotten; in erofs_read_inode()
90 die = copied; in erofs_read_inode()
92 vi->xattr_isize = erofs_xattr_ibody_size(die->i_xattr_icount); in erofs_read_inode()
94 inode->i_mode = le16_to_cpu(die->i_mode); in erofs_read_inode()
95 switch (inode->i_mode & S_IFMT) { in erofs_read_inode()
99 vi->raw_blkaddr = le32_to_cpu(die->i_u.raw_blkaddr); in erofs_read_inode()
103 inode->i_rdev = in erofs_read_inode()
104 new_decode_dev(le32_to_cpu(die->i_u.rdev)); in erofs_read_inode()
108 inode->i_rdev = 0; in erofs_read_inode()
113 i_uid_write(inode, le32_to_cpu(die->i_uid)); in erofs_read_inode()
114 i_gid_write(inode, le32_to_cpu(die->i_gid)); in erofs_read_inode()
115 set_nlink(inode, le32_to_cpu(die->i_nlink)); in erofs_read_inode()
118 inode->i_ctime.tv_sec = le64_to_cpu(die->i_ctime); in erofs_read_inode()
119 inode->i_ctime.tv_nsec = le32_to_cpu(die->i_ctime_nsec); in erofs_read_inode()
121 inode->i_size = le64_to_cpu(die->i_size); in erofs_read_inode()
124 if (erofs_inode_is_data_compressed(vi->datalayout)) in erofs_read_inode()
125 nblks = le32_to_cpu(die->i_u.compressed_blocks); in erofs_read_inode()
126 else if (vi->datalayout == EROFS_INODE_CHUNK_BASED) in erofs_read_inode()
128 vi->chunkformat = le16_to_cpu(die->i_u.c.format); in erofs_read_inode()
133 vi->inode_isize = sizeof(struct erofs_inode_compact); in erofs_read_inode()
134 *ofs += vi->inode_isize; in erofs_read_inode()
135 vi->xattr_isize = erofs_xattr_ibody_size(dic->i_xattr_icount); in erofs_read_inode()
137 inode->i_mode = le16_to_cpu(dic->i_mode); in erofs_read_inode()
138 switch (inode->i_mode & S_IFMT) { in erofs_read_inode()
142 vi->raw_blkaddr = le32_to_cpu(dic->i_u.raw_blkaddr); in erofs_read_inode()
146 inode->i_rdev = in erofs_read_inode()
147 new_decode_dev(le32_to_cpu(dic->i_u.rdev)); in erofs_read_inode()
151 inode->i_rdev = 0; in erofs_read_inode()
156 i_uid_write(inode, le16_to_cpu(dic->i_uid)); in erofs_read_inode()
157 i_gid_write(inode, le16_to_cpu(dic->i_gid)); in erofs_read_inode()
158 set_nlink(inode, le16_to_cpu(dic->i_nlink)); in erofs_read_inode()
161 inode->i_ctime.tv_sec = sbi->build_time; in erofs_read_inode()
162 inode->i_ctime.tv_nsec = sbi->build_time_nsec; in erofs_read_inode()
164 inode->i_size = le32_to_cpu(dic->i_size); in erofs_read_inode()
165 if (erofs_inode_is_data_compressed(vi->datalayout)) in erofs_read_inode()
166 nblks = le32_to_cpu(dic->i_u.compressed_blocks); in erofs_read_inode()
167 else if (vi->datalayout == EROFS_INODE_CHUNK_BASED) in erofs_read_inode()
168 vi->chunkformat = le16_to_cpu(dic->i_u.c.format); in erofs_read_inode()
171 erofs_err(inode->i_sb, in erofs_read_inode()
172 "unsupported on-disk inode version %u of nid %llu", in erofs_read_inode()
173 erofs_inode_version(ifmt), vi->nid); in erofs_read_inode()
174 err = -EOPNOTSUPP; in erofs_read_inode()
178 if (vi->datalayout == EROFS_INODE_CHUNK_BASED) { in erofs_read_inode()
179 if (vi->chunkformat & ~EROFS_CHUNK_FORMAT_ALL) { in erofs_read_inode()
180 erofs_err(inode->i_sb, in erofs_read_inode()
182 vi->chunkformat, vi->nid); in erofs_read_inode()
183 err = -EOPNOTSUPP; in erofs_read_inode()
186 vi->chunkbits = LOG_BLOCK_SIZE + in erofs_read_inode()
187 (vi->chunkformat & EROFS_CHUNK_FORMAT_BLKBITS_MASK); in erofs_read_inode()
189 inode->i_mtime.tv_sec = inode->i_ctime.tv_sec; in erofs_read_inode()
190 inode->i_atime.tv_sec = inode->i_ctime.tv_sec; in erofs_read_inode()
191 inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec; in erofs_read_inode()
192 inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec; in erofs_read_inode()
194 inode->i_flags &= ~S_DAX; in erofs_read_inode()
195 if (test_opt(&sbi->ctx, DAX_ALWAYS) && S_ISREG(inode->i_mode) && in erofs_read_inode()
196 vi->datalayout == EROFS_INODE_FLAT_PLAIN) in erofs_read_inode()
197 inode->i_flags |= S_DAX; in erofs_read_inode()
200 inode->i_blocks = roundup(inode->i_size, EROFS_BLKSIZ) >> 9; in erofs_read_inode()
202 inode->i_blocks = nblks << LOG_SECTORS_PER_BLOCK; in erofs_read_inode()
206 erofs_err(inode->i_sb, "bogus i_mode (%o) @ nid %llu", in erofs_read_inode()
207 inode->i_mode, vi->nid); in erofs_read_inode()
208 err = -EFSCORRUPTED; in erofs_read_inode()
224 if (vi->datalayout != EROFS_INODE_FLAT_INLINE || in erofs_fill_symlink()
225 inode->i_size >= PAGE_SIZE) { in erofs_fill_symlink()
226 inode->i_op = &erofs_symlink_iops; in erofs_fill_symlink()
230 lnk = kmalloc(inode->i_size + 1, GFP_KERNEL); in erofs_fill_symlink()
232 return -ENOMEM; in erofs_fill_symlink()
234 m_pofs += vi->xattr_isize; in erofs_fill_symlink()
236 if (m_pofs + inode->i_size > PAGE_SIZE) { in erofs_fill_symlink()
238 erofs_err(inode->i_sb, in erofs_fill_symlink()
240 vi->nid); in erofs_fill_symlink()
242 return -EFSCORRUPTED; in erofs_fill_symlink()
245 memcpy(lnk, data + m_pofs, inode->i_size); in erofs_fill_symlink()
246 lnk[inode->i_size] = '\0'; in erofs_fill_symlink()
248 inode->i_link = lnk; in erofs_fill_symlink()
249 inode->i_op = &erofs_fast_symlink_iops; in erofs_fill_symlink()
268 switch (inode->i_mode & S_IFMT) { in erofs_fill_inode()
270 inode->i_op = &erofs_generic_iops; in erofs_fill_inode()
271 if (erofs_inode_is_data_compressed(vi->datalayout)) in erofs_fill_inode()
272 inode->i_fop = &generic_ro_fops; in erofs_fill_inode()
274 inode->i_fop = &erofs_file_fops; in erofs_fill_inode()
277 inode->i_op = &erofs_dir_iops; in erofs_fill_inode()
278 inode->i_fop = &erofs_dir_fops; in erofs_fill_inode()
290 inode->i_op = &erofs_generic_iops; in erofs_fill_inode()
291 init_special_inode(inode, inode->i_mode, inode->i_rdev); in erofs_fill_inode()
294 err = -EFSCORRUPTED; in erofs_fill_inode()
298 if (erofs_inode_is_data_compressed(vi->datalayout)) { in erofs_fill_inode()
302 inode->i_mapping->a_ops = &erofs_raw_access_aops; in erofs_fill_inode()
312 * we should do more for 32-bit platform to find the right inode.
318 return EROFS_I(inode)->nid == nid; in erofs_ilookup_test_actor()
325 inode->i_ino = erofs_inode_hash(nid); in erofs_iget_set_actor()
345 return ERR_PTR(-ENOMEM); in erofs_iget()
347 if (inode->i_state & I_NEW) { in erofs_iget()
351 vi->nid = nid; in erofs_iget()
368 struct inode *const inode = d_inode(path->dentry); in erofs_getattr()
370 if (erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout)) in erofs_getattr()
371 stat->attributes |= STATX_ATTR_COMPRESSED; in erofs_getattr()
373 stat->attributes |= STATX_ATTR_IMMUTABLE; in erofs_getattr()
374 stat->attributes_mask |= (STATX_ATTR_COMPRESSED | in erofs_getattr()