Lines Matching refs:inode

44 	struct inode *inode = mapping->host;  in hfs_write_failed()  local
46 if (to > inode->i_size) { in hfs_write_failed()
47 truncate_pagecache(inode, inode->i_size); in hfs_write_failed()
48 hfs_file_truncate(inode); in hfs_write_failed()
74 struct inode *inode = folio->mapping->host; in hfs_release_folio() local
75 struct super_block *sb = inode->i_sb; in hfs_release_folio()
82 switch (inode->i_ino) { in hfs_release_folio()
134 struct inode *inode = mapping->host; in hfs_direct_IO() local
138 ret = blockdev_direct_IO(iocb, inode, iter, hfs_get_block); in hfs_direct_IO()
145 loff_t isize = i_size_read(inode); in hfs_direct_IO()
187 struct inode *hfs_new_inode(struct inode *dir, const struct qstr *name, umode_t mode) in hfs_new_inode()
190 struct inode *inode = new_inode(sb); in hfs_new_inode() local
191 if (!inode) in hfs_new_inode()
194 mutex_init(&HFS_I(inode)->extents_lock); in hfs_new_inode()
195 INIT_LIST_HEAD(&HFS_I(inode)->open_dir_list); in hfs_new_inode()
196 spin_lock_init(&HFS_I(inode)->open_dir_lock); in hfs_new_inode()
197 hfs_cat_build_key(sb, (btree_key *)&HFS_I(inode)->cat_key, dir->i_ino, name); in hfs_new_inode()
198 inode->i_ino = HFS_SB(sb)->next_id++; in hfs_new_inode()
199 inode->i_mode = mode; in hfs_new_inode()
200 inode->i_uid = current_fsuid(); in hfs_new_inode()
201 inode->i_gid = current_fsgid(); in hfs_new_inode()
202 set_nlink(inode, 1); in hfs_new_inode()
203 inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); in hfs_new_inode()
204 HFS_I(inode)->flags = 0; in hfs_new_inode()
205 HFS_I(inode)->rsrc_inode = NULL; in hfs_new_inode()
206 HFS_I(inode)->fs_blocks = 0; in hfs_new_inode()
208 inode->i_size = 2; in hfs_new_inode()
212 inode->i_op = &hfs_dir_inode_operations; in hfs_new_inode()
213 inode->i_fop = &hfs_dir_operations; in hfs_new_inode()
214 inode->i_mode |= S_IRWXUGO; in hfs_new_inode()
215 inode->i_mode &= ~HFS_SB(inode->i_sb)->s_dir_umask; in hfs_new_inode()
217 HFS_I(inode)->clump_blocks = HFS_SB(sb)->clumpablks; in hfs_new_inode()
221 inode->i_op = &hfs_file_inode_operations; in hfs_new_inode()
222 inode->i_fop = &hfs_file_operations; in hfs_new_inode()
223 inode->i_mapping->a_ops = &hfs_aops; in hfs_new_inode()
224 inode->i_mode |= S_IRUGO|S_IXUGO; in hfs_new_inode()
226 inode->i_mode |= S_IWUGO; in hfs_new_inode()
227 inode->i_mode &= ~HFS_SB(inode->i_sb)->s_file_umask; in hfs_new_inode()
228 HFS_I(inode)->phys_size = 0; in hfs_new_inode()
229 HFS_I(inode)->alloc_blocks = 0; in hfs_new_inode()
230 HFS_I(inode)->first_blocks = 0; in hfs_new_inode()
231 HFS_I(inode)->cached_start = 0; in hfs_new_inode()
232 HFS_I(inode)->cached_blocks = 0; in hfs_new_inode()
233 memset(HFS_I(inode)->first_extents, 0, sizeof(hfs_extent_rec)); in hfs_new_inode()
234 memset(HFS_I(inode)->cached_extents, 0, sizeof(hfs_extent_rec)); in hfs_new_inode()
236 insert_inode_hash(inode); in hfs_new_inode()
237 mark_inode_dirty(inode); in hfs_new_inode()
241 return inode; in hfs_new_inode()
244 void hfs_delete_inode(struct inode *inode) in hfs_delete_inode() argument
246 struct super_block *sb = inode->i_sb; in hfs_delete_inode()
248 hfs_dbg(INODE, "delete_inode: %lu\n", inode->i_ino); in hfs_delete_inode()
249 if (S_ISDIR(inode->i_mode)) { in hfs_delete_inode()
251 if (HFS_I(inode)->cat_key.ParID == cpu_to_be32(HFS_ROOT_CNID)) in hfs_delete_inode()
258 if (HFS_I(inode)->cat_key.ParID == cpu_to_be32(HFS_ROOT_CNID)) in hfs_delete_inode()
260 if (S_ISREG(inode->i_mode)) { in hfs_delete_inode()
261 if (!inode->i_nlink) { in hfs_delete_inode()
262 inode->i_size = 0; in hfs_delete_inode()
263 hfs_file_truncate(inode); in hfs_delete_inode()
270 void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext, in hfs_inode_read_fork() argument
273 struct super_block *sb = inode->i_sb; in hfs_inode_read_fork()
278 memcpy(HFS_I(inode)->first_extents, ext, sizeof(hfs_extent_rec)); in hfs_inode_read_fork()
281 HFS_I(inode)->first_blocks = count; in hfs_inode_read_fork()
283 inode->i_size = HFS_I(inode)->phys_size = log_size; in hfs_inode_read_fork()
284 HFS_I(inode)->fs_blocks = (log_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits; in hfs_inode_read_fork()
285 inode_set_bytes(inode, HFS_I(inode)->fs_blocks << sb->s_blocksize_bits); in hfs_inode_read_fork()
286 HFS_I(inode)->alloc_blocks = be32_to_cpu(phys_size) / in hfs_inode_read_fork()
288 HFS_I(inode)->clump_blocks = clump_size / HFS_SB(sb)->alloc_blksz; in hfs_inode_read_fork()
289 if (!HFS_I(inode)->clump_blocks) in hfs_inode_read_fork()
290 HFS_I(inode)->clump_blocks = HFS_SB(sb)->clumpablks; in hfs_inode_read_fork()
298 static int hfs_test_inode(struct inode *inode, void *data) in hfs_test_inode() argument
306 return inode->i_ino == be32_to_cpu(rec->dir.DirID); in hfs_test_inode()
308 return inode->i_ino == be32_to_cpu(rec->file.FlNum); in hfs_test_inode()
318 static int hfs_read_inode(struct inode *inode, void *data) in hfs_read_inode() argument
321 struct hfs_sb_info *hsb = HFS_SB(inode->i_sb); in hfs_read_inode()
324 HFS_I(inode)->flags = 0; in hfs_read_inode()
325 HFS_I(inode)->rsrc_inode = NULL; in hfs_read_inode()
326 mutex_init(&HFS_I(inode)->extents_lock); in hfs_read_inode()
327 INIT_LIST_HEAD(&HFS_I(inode)->open_dir_list); in hfs_read_inode()
328 spin_lock_init(&HFS_I(inode)->open_dir_lock); in hfs_read_inode()
331 inode->i_uid = hsb->s_uid; in hfs_read_inode()
332 inode->i_gid = hsb->s_gid; in hfs_read_inode()
333 set_nlink(inode, 1); in hfs_read_inode()
336 HFS_I(inode)->cat_key = *idata->key; in hfs_read_inode()
338 HFS_I(inode)->flags |= HFS_FLG_RSRC; in hfs_read_inode()
339 HFS_I(inode)->tz_secondswest = sys_tz.tz_minuteswest * 60; in hfs_read_inode()
344 if (!HFS_IS_RSRC(inode)) { in hfs_read_inode()
345 hfs_inode_read_fork(inode, rec->file.ExtRec, rec->file.LgLen, in hfs_read_inode()
348 hfs_inode_read_fork(inode, rec->file.RExtRec, rec->file.RLgLen, in hfs_read_inode()
352 inode->i_ino = be32_to_cpu(rec->file.FlNum); in hfs_read_inode()
353 inode->i_mode = S_IRUGO | S_IXUGO; in hfs_read_inode()
355 inode->i_mode |= S_IWUGO; in hfs_read_inode()
356 inode->i_mode &= ~hsb->s_file_umask; in hfs_read_inode()
357 inode->i_mode |= S_IFREG; in hfs_read_inode()
358 inode->i_ctime = inode->i_atime = inode->i_mtime = in hfs_read_inode()
360 inode->i_op = &hfs_file_inode_operations; in hfs_read_inode()
361 inode->i_fop = &hfs_file_operations; in hfs_read_inode()
362 inode->i_mapping->a_ops = &hfs_aops; in hfs_read_inode()
365 inode->i_ino = be32_to_cpu(rec->dir.DirID); in hfs_read_inode()
366 inode->i_size = be16_to_cpu(rec->dir.Val) + 2; in hfs_read_inode()
367 HFS_I(inode)->fs_blocks = 0; in hfs_read_inode()
368 inode->i_mode = S_IFDIR | (S_IRWXUGO & ~hsb->s_dir_umask); in hfs_read_inode()
369 inode->i_ctime = inode->i_atime = inode->i_mtime = in hfs_read_inode()
371 inode->i_op = &hfs_dir_inode_operations; in hfs_read_inode()
372 inode->i_fop = &hfs_dir_operations; in hfs_read_inode()
375 make_bad_inode(inode); in hfs_read_inode()
389 struct inode *hfs_iget(struct super_block *sb, struct hfs_cat_key *key, hfs_cat_rec *rec) in hfs_iget()
392 struct inode *inode; in hfs_iget() local
405 inode = iget5_locked(sb, cnid, hfs_test_inode, hfs_read_inode, &data); in hfs_iget()
406 if (inode && (inode->i_state & I_NEW)) in hfs_iget()
407 unlock_new_inode(inode); in hfs_iget()
408 return inode; in hfs_iget()
411 void hfs_inode_write_fork(struct inode *inode, struct hfs_extent *ext, in hfs_inode_write_fork() argument
414 memcpy(ext, HFS_I(inode)->first_extents, sizeof(hfs_extent_rec)); in hfs_inode_write_fork()
417 *log_size = cpu_to_be32(inode->i_size); in hfs_inode_write_fork()
419 *phys_size = cpu_to_be32(HFS_I(inode)->alloc_blocks * in hfs_inode_write_fork()
420 HFS_SB(inode->i_sb)->alloc_blksz); in hfs_inode_write_fork()
423 int hfs_write_inode(struct inode *inode, struct writeback_control *wbc) in hfs_write_inode() argument
425 struct inode *main_inode = inode; in hfs_write_inode()
430 hfs_dbg(INODE, "hfs_write_inode: %lu\n", inode->i_ino); in hfs_write_inode()
431 res = hfs_ext_write_extent(inode); in hfs_write_inode()
435 if (inode->i_ino < HFS_FIRSTUSER_CNID) { in hfs_write_inode()
436 switch (inode->i_ino) { in hfs_write_inode()
440 hfs_btree_write(HFS_SB(inode->i_sb)->ext_tree); in hfs_write_inode()
443 hfs_btree_write(HFS_SB(inode->i_sb)->cat_tree); in hfs_write_inode()
451 if (HFS_IS_RSRC(inode)) in hfs_write_inode()
452 main_inode = HFS_I(inode)->rsrc_inode; in hfs_write_inode()
474 be32_to_cpu(rec.dir.DirID) != inode->i_ino) { in hfs_write_inode()
477 rec.dir.MdDat = hfs_u_to_mtime(inode->i_mtime); in hfs_write_inode()
478 rec.dir.Val = cpu_to_be16(inode->i_size - 2); in hfs_write_inode()
482 } else if (HFS_IS_RSRC(inode)) { in hfs_write_inode()
487 hfs_inode_write_fork(inode, rec.file.RExtRec, in hfs_write_inode()
497 be32_to_cpu(rec.file.FlNum) != inode->i_ino) { in hfs_write_inode()
500 if (inode->i_mode & S_IWUSR) in hfs_write_inode()
504 hfs_inode_write_fork(inode, rec.file.ExtRec, &rec.file.LgLen, &rec.file.PyLen); in hfs_write_inode()
505 rec.file.MdDat = hfs_u_to_mtime(inode->i_mtime); in hfs_write_inode()
516 static struct dentry *hfs_file_lookup(struct inode *dir, struct dentry *dentry, in hfs_file_lookup()
519 struct inode *inode = NULL; in hfs_file_lookup() local
527 inode = HFS_I(dir)->rsrc_inode; in hfs_file_lookup()
528 if (inode) in hfs_file_lookup()
531 inode = new_inode(dir->i_sb); in hfs_file_lookup()
532 if (!inode) in hfs_file_lookup()
537 iput(inode); in hfs_file_lookup()
544 hfs_read_inode(inode, &idata); in hfs_file_lookup()
548 iput(inode); in hfs_file_lookup()
551 HFS_I(inode)->rsrc_inode = dir; in hfs_file_lookup()
552 HFS_I(dir)->rsrc_inode = inode; in hfs_file_lookup()
554 inode_fake_hash(inode); in hfs_file_lookup()
555 mark_inode_dirty(inode); in hfs_file_lookup()
558 return d_splice_alias(inode, dentry); in hfs_file_lookup()
561 void hfs_evict_inode(struct inode *inode) in hfs_evict_inode() argument
563 truncate_inode_pages_final(&inode->i_data); in hfs_evict_inode()
564 clear_inode(inode); in hfs_evict_inode()
565 if (HFS_IS_RSRC(inode) && HFS_I(inode)->rsrc_inode) { in hfs_evict_inode()
566 HFS_I(HFS_I(inode)->rsrc_inode)->rsrc_inode = NULL; in hfs_evict_inode()
567 iput(HFS_I(inode)->rsrc_inode); in hfs_evict_inode()
571 static int hfs_file_open(struct inode *inode, struct file *file) in hfs_file_open() argument
573 if (HFS_IS_RSRC(inode)) in hfs_file_open()
574 inode = HFS_I(inode)->rsrc_inode; in hfs_file_open()
575 atomic_inc(&HFS_I(inode)->opencnt); in hfs_file_open()
579 static int hfs_file_release(struct inode *inode, struct file *file) in hfs_file_release() argument
583 if (HFS_IS_RSRC(inode)) in hfs_file_release()
584 inode = HFS_I(inode)->rsrc_inode; in hfs_file_release()
585 if (atomic_dec_and_test(&HFS_I(inode)->opencnt)) { in hfs_file_release()
586 inode_lock(inode); in hfs_file_release()
587 hfs_file_truncate(inode); in hfs_file_release()
592 inode_unlock(inode); in hfs_file_release()
617 struct inode *inode = d_inode(dentry); in hfs_inode_setattr() local
618 struct hfs_sb_info *hsb = HFS_SB(inode->i_sb); in hfs_inode_setattr()
632 ((S_ISDIR(inode->i_mode) && in hfs_inode_setattr()
633 (attr->ia_mode != inode->i_mode)) || in hfs_inode_setattr()
641 attr->ia_mode = inode->i_mode | S_IWUGO; in hfs_inode_setattr()
643 attr->ia_mode = inode->i_mode & ~S_IWUGO; in hfs_inode_setattr()
644 attr->ia_mode &= S_ISDIR(inode->i_mode) ? ~hsb->s_dir_umask: ~hsb->s_file_umask; in hfs_inode_setattr()
648 attr->ia_size != i_size_read(inode)) { in hfs_inode_setattr()
649 inode_dio_wait(inode); in hfs_inode_setattr()
651 error = inode_newsize_ok(inode, attr->ia_size); in hfs_inode_setattr()
655 truncate_setsize(inode, attr->ia_size); in hfs_inode_setattr()
656 hfs_file_truncate(inode); in hfs_inode_setattr()
657 inode->i_atime = inode->i_mtime = inode->i_ctime = in hfs_inode_setattr()
658 current_time(inode); in hfs_inode_setattr()
661 setattr_copy(&nop_mnt_idmap, inode, attr); in hfs_inode_setattr()
662 mark_inode_dirty(inode); in hfs_inode_setattr()
669 struct inode *inode = filp->f_mapping->host; in hfs_file_fsync() local
676 inode_lock(inode); in hfs_file_fsync()
679 ret = write_inode_now(inode, 0); in hfs_file_fsync()
682 sb = inode->i_sb; in hfs_file_fsync()
688 inode_unlock(inode); in hfs_file_fsync()