• Home
  • Raw
  • Download

Lines Matching refs:inode

44 static int ext2_update_inode(struct inode * inode, int do_sync);
49 static inline int ext2_inode_is_fast_symlink(struct inode *inode) in ext2_inode_is_fast_symlink() argument
51 int ea_blocks = EXT2_I(inode)->i_file_acl ? in ext2_inode_is_fast_symlink()
52 (inode->i_sb->s_blocksize >> 9) : 0; in ext2_inode_is_fast_symlink()
54 return (S_ISLNK(inode->i_mode) && in ext2_inode_is_fast_symlink()
55 inode->i_blocks - ea_blocks == 0); in ext2_inode_is_fast_symlink()
61 void ext2_delete_inode (struct inode * inode) in ext2_delete_inode() argument
63 truncate_inode_pages(&inode->i_data, 0); in ext2_delete_inode()
65 if (is_bad_inode(inode)) in ext2_delete_inode()
67 EXT2_I(inode)->i_dtime = get_seconds(); in ext2_delete_inode()
68 mark_inode_dirty(inode); in ext2_delete_inode()
69 ext2_update_inode(inode, inode_needs_sync(inode)); in ext2_delete_inode()
71 inode->i_size = 0; in ext2_delete_inode()
72 if (inode->i_blocks) in ext2_delete_inode()
73 ext2_truncate (inode); in ext2_delete_inode()
74 ext2_free_inode (inode); in ext2_delete_inode()
78 clear_inode(inode); /* We must guarantee clearing of inode... */ in ext2_delete_inode()
130 static int ext2_block_to_path(struct inode *inode, in ext2_block_to_path() argument
133 int ptrs = EXT2_ADDR_PER_BLOCK(inode->i_sb); in ext2_block_to_path()
134 int ptrs_bits = EXT2_ADDR_PER_BLOCK_BITS(inode->i_sb); in ext2_block_to_path()
142 ext2_warning (inode->i_sb, "ext2_block_to_path", "block < 0"); in ext2_block_to_path()
162 ext2_warning (inode->i_sb, "ext2_block_to_path", "block > big"); in ext2_block_to_path()
199 static Indirect *ext2_get_branch(struct inode *inode, in ext2_get_branch() argument
205 struct super_block *sb = inode->i_sb; in ext2_get_branch()
211 add_chain (chain, NULL, EXT2_I(inode)->i_data + *offsets); in ext2_get_branch()
218 read_lock(&EXT2_I(inode)->i_meta_lock); in ext2_get_branch()
222 read_unlock(&EXT2_I(inode)->i_meta_lock); in ext2_get_branch()
229 read_unlock(&EXT2_I(inode)->i_meta_lock); in ext2_get_branch()
259 static ext2_fsblk_t ext2_find_near(struct inode *inode, Indirect *ind) in ext2_find_near() argument
261 struct ext2_inode_info *ei = EXT2_I(inode); in ext2_find_near()
280 bg_start = ext2_group_first_block_no(inode->i_sb, ei->i_block_group); in ext2_find_near()
282 (EXT2_BLOCKS_PER_GROUP(inode->i_sb) / 16); in ext2_find_near()
295 static inline ext2_fsblk_t ext2_find_goal(struct inode *inode, long block, in ext2_find_goal() argument
300 block_i = EXT2_I(inode)->i_block_alloc_info; in ext2_find_goal()
311 return ext2_find_near(inode, partial); in ext2_find_goal()
363 static int ext2_alloc_blocks(struct inode *inode, in ext2_alloc_blocks() argument
386 current_block = ext2_new_blocks(inode,goal,&count,err); in ext2_alloc_blocks()
410 ext2_free_blocks(inode, new_blocks[i], 1); in ext2_alloc_blocks()
439 static int ext2_alloc_branch(struct inode *inode, in ext2_alloc_branch() argument
443 int blocksize = inode->i_sb->s_blocksize; in ext2_alloc_branch()
451 num = ext2_alloc_blocks(inode, goal, indirect_blks, in ext2_alloc_branch()
466 bh = sb_getblk(inode->i_sb, new_blocks[n-1]); in ext2_alloc_branch()
485 mark_buffer_dirty_inode(bh, inode); in ext2_alloc_branch()
490 if (S_ISDIR(inode->i_mode) && IS_DIRSYNC(inode)) in ext2_alloc_branch()
509 static void ext2_splice_branch(struct inode *inode, in ext2_splice_branch() argument
516 block_i = EXT2_I(inode)->i_block_alloc_info; in ext2_splice_branch()
548 mark_buffer_dirty_inode(where->bh, inode); in ext2_splice_branch()
550 inode->i_ctime = CURRENT_TIME_SEC; in ext2_splice_branch()
551 mark_inode_dirty(inode); in ext2_splice_branch()
572 static int ext2_get_blocks(struct inode *inode, in ext2_get_blocks() argument
585 struct ext2_inode_info *ei = EXT2_I(inode); in ext2_get_blocks()
589 depth = ext2_block_to_path(inode,iblock,offsets,&blocks_to_boundary); in ext2_get_blocks()
594 partial = ext2_get_branch(inode, depth, offsets, chain, &err); in ext2_get_blocks()
634 if (S_ISREG(inode->i_mode) && (!ei->i_block_alloc_info)) in ext2_get_blocks()
635 ext2_init_block_alloc_info(inode); in ext2_get_blocks()
637 goal = ext2_find_goal(inode, iblock, partial); in ext2_get_blocks()
650 err = ext2_alloc_branch(inode, indirect_blks, &count, goal, in ext2_get_blocks()
658 if (ext2_use_xip(inode->i_sb)) { in ext2_get_blocks()
662 err = ext2_clear_xip_target (inode, in ext2_get_blocks()
670 ext2_splice_branch(inode, iblock, partial, indirect_blks, count); in ext2_get_blocks()
674 map_bh(bh_result, inode->i_sb, le32_to_cpu(chain[depth-1].key)); in ext2_get_blocks()
694 int ext2_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) in ext2_get_block() argument
696 unsigned max_blocks = bh_result->b_size >> inode->i_blkbits; in ext2_get_block()
697 int ret = ext2_get_blocks(inode, iblock, max_blocks, in ext2_get_block()
700 bh_result->b_size = (ret << inode->i_blkbits); in ext2_get_block()
707 int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, in ext2_fiemap() argument
710 return generic_block_fiemap(inode, fieinfo, start, len, in ext2_fiemap()
778 struct inode *inode = file->f_mapping->host; in ext2_direct_IO() local
780 return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, in ext2_direct_IO()
869 static Indirect *ext2_find_shared(struct inode *inode, in ext2_find_shared() argument
881 partial = ext2_get_branch(inode, k, offsets, chain, &err); in ext2_find_shared()
888 write_lock(&EXT2_I(inode)->i_meta_lock); in ext2_find_shared()
890 write_unlock(&EXT2_I(inode)->i_meta_lock); in ext2_find_shared()
907 write_unlock(&EXT2_I(inode)->i_meta_lock); in ext2_find_shared()
928 static inline void ext2_free_data(struct inode *inode, __le32 *p, __le32 *q) in ext2_free_data() argument
943 mark_inode_dirty(inode); in ext2_free_data()
944 ext2_free_blocks (inode, block_to_free, count); in ext2_free_data()
952 mark_inode_dirty(inode); in ext2_free_data()
953 ext2_free_blocks (inode, block_to_free, count); in ext2_free_data()
968 static void ext2_free_branches(struct inode *inode, __le32 *p, __le32 *q, int depth) in ext2_free_branches() argument
974 int addr_per_block = EXT2_ADDR_PER_BLOCK(inode->i_sb); in ext2_free_branches()
980 bh = sb_bread(inode->i_sb, nr); in ext2_free_branches()
986 ext2_error(inode->i_sb, "ext2_free_branches", in ext2_free_branches()
988 inode->i_ino, nr); in ext2_free_branches()
991 ext2_free_branches(inode, in ext2_free_branches()
996 ext2_free_blocks(inode, nr, 1); in ext2_free_branches()
997 mark_inode_dirty(inode); in ext2_free_branches()
1000 ext2_free_data(inode, p, q); in ext2_free_branches()
1003 void ext2_truncate(struct inode *inode) in ext2_truncate() argument
1005 __le32 *i_data = EXT2_I(inode)->i_data; in ext2_truncate()
1006 struct ext2_inode_info *ei = EXT2_I(inode); in ext2_truncate()
1007 int addr_per_block = EXT2_ADDR_PER_BLOCK(inode->i_sb); in ext2_truncate()
1016 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || in ext2_truncate()
1017 S_ISLNK(inode->i_mode))) in ext2_truncate()
1019 if (ext2_inode_is_fast_symlink(inode)) in ext2_truncate()
1021 if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) in ext2_truncate()
1024 blocksize = inode->i_sb->s_blocksize; in ext2_truncate()
1025 iblock = (inode->i_size + blocksize-1) in ext2_truncate()
1026 >> EXT2_BLOCK_SIZE_BITS(inode->i_sb); in ext2_truncate()
1028 if (mapping_is_xip(inode->i_mapping)) in ext2_truncate()
1029 xip_truncate_page(inode->i_mapping, inode->i_size); in ext2_truncate()
1030 else if (test_opt(inode->i_sb, NOBH)) in ext2_truncate()
1031 nobh_truncate_page(inode->i_mapping, in ext2_truncate()
1032 inode->i_size, ext2_get_block); in ext2_truncate()
1034 block_truncate_page(inode->i_mapping, in ext2_truncate()
1035 inode->i_size, ext2_get_block); in ext2_truncate()
1037 n = ext2_block_to_path(inode, iblock, offsets, NULL); in ext2_truncate()
1048 ext2_free_data(inode, i_data+offsets[0], in ext2_truncate()
1053 partial = ext2_find_shared(inode, n, offsets, chain, &nr); in ext2_truncate()
1057 mark_inode_dirty(inode); in ext2_truncate()
1059 mark_buffer_dirty_inode(partial->bh, inode); in ext2_truncate()
1060 ext2_free_branches(inode, &nr, &nr+1, (chain+n-1) - partial); in ext2_truncate()
1064 ext2_free_branches(inode, in ext2_truncate()
1068 mark_buffer_dirty_inode(partial->bh, inode); in ext2_truncate()
1079 mark_inode_dirty(inode); in ext2_truncate()
1080 ext2_free_branches(inode, &nr, &nr+1, 1); in ext2_truncate()
1086 mark_inode_dirty(inode); in ext2_truncate()
1087 ext2_free_branches(inode, &nr, &nr+1, 2); in ext2_truncate()
1093 mark_inode_dirty(inode); in ext2_truncate()
1094 ext2_free_branches(inode, &nr, &nr+1, 3); in ext2_truncate()
1100 ext2_discard_reservation(inode); in ext2_truncate()
1103 inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; in ext2_truncate()
1104 if (inode_needs_sync(inode)) { in ext2_truncate()
1105 sync_mapping_buffers(inode->i_mapping); in ext2_truncate()
1106 ext2_sync_inode (inode); in ext2_truncate()
1108 mark_inode_dirty(inode); in ext2_truncate()
1155 void ext2_set_inode_flags(struct inode *inode) in ext2_set_inode_flags() argument
1157 unsigned int flags = EXT2_I(inode)->i_flags; in ext2_set_inode_flags()
1159 inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC); in ext2_set_inode_flags()
1161 inode->i_flags |= S_SYNC; in ext2_set_inode_flags()
1163 inode->i_flags |= S_APPEND; in ext2_set_inode_flags()
1165 inode->i_flags |= S_IMMUTABLE; in ext2_set_inode_flags()
1167 inode->i_flags |= S_NOATIME; in ext2_set_inode_flags()
1169 inode->i_flags |= S_DIRSYNC; in ext2_set_inode_flags()
1191 struct inode *ext2_iget (struct super_block *sb, unsigned long ino) in ext2_iget()
1196 struct inode *inode; in ext2_iget() local
1200 inode = iget_locked(sb, ino); in ext2_iget()
1201 if (!inode) in ext2_iget()
1203 if (!(inode->i_state & I_NEW)) in ext2_iget()
1204 return inode; in ext2_iget()
1206 ei = EXT2_I(inode); in ext2_iget()
1213 raw_inode = ext2_get_inode(inode->i_sb, ino, &bh); in ext2_iget()
1219 inode->i_mode = le16_to_cpu(raw_inode->i_mode); in ext2_iget()
1220 inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low); in ext2_iget()
1221 inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low); in ext2_iget()
1222 if (!(test_opt (inode->i_sb, NO_UID32))) { in ext2_iget()
1223 inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16; in ext2_iget()
1224 inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16; in ext2_iget()
1226 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count); in ext2_iget()
1227 inode->i_size = le32_to_cpu(raw_inode->i_size); in ext2_iget()
1228 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime); in ext2_iget()
1229 inode->i_ctime.tv_sec = (signed)le32_to_cpu(raw_inode->i_ctime); in ext2_iget()
1230 inode->i_mtime.tv_sec = (signed)le32_to_cpu(raw_inode->i_mtime); in ext2_iget()
1231 inode->i_atime.tv_nsec = inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = 0; in ext2_iget()
1238 if (inode->i_nlink == 0 && (inode->i_mode == 0 || ei->i_dtime)) { in ext2_iget()
1244 inode->i_blocks = le32_to_cpu(raw_inode->i_blocks); in ext2_iget()
1251 if (S_ISREG(inode->i_mode)) in ext2_iget()
1252 inode->i_size |= ((__u64)le32_to_cpu(raw_inode->i_size_high)) << 32; in ext2_iget()
1256 inode->i_generation = le32_to_cpu(raw_inode->i_generation); in ext2_iget()
1258 ei->i_block_group = (ino - 1) / EXT2_INODES_PER_GROUP(inode->i_sb); in ext2_iget()
1268 if (S_ISREG(inode->i_mode)) { in ext2_iget()
1269 inode->i_op = &ext2_file_inode_operations; in ext2_iget()
1270 if (ext2_use_xip(inode->i_sb)) { in ext2_iget()
1271 inode->i_mapping->a_ops = &ext2_aops_xip; in ext2_iget()
1272 inode->i_fop = &ext2_xip_file_operations; in ext2_iget()
1273 } else if (test_opt(inode->i_sb, NOBH)) { in ext2_iget()
1274 inode->i_mapping->a_ops = &ext2_nobh_aops; in ext2_iget()
1275 inode->i_fop = &ext2_file_operations; in ext2_iget()
1277 inode->i_mapping->a_ops = &ext2_aops; in ext2_iget()
1278 inode->i_fop = &ext2_file_operations; in ext2_iget()
1280 } else if (S_ISDIR(inode->i_mode)) { in ext2_iget()
1281 inode->i_op = &ext2_dir_inode_operations; in ext2_iget()
1282 inode->i_fop = &ext2_dir_operations; in ext2_iget()
1283 if (test_opt(inode->i_sb, NOBH)) in ext2_iget()
1284 inode->i_mapping->a_ops = &ext2_nobh_aops; in ext2_iget()
1286 inode->i_mapping->a_ops = &ext2_aops; in ext2_iget()
1287 } else if (S_ISLNK(inode->i_mode)) { in ext2_iget()
1288 if (ext2_inode_is_fast_symlink(inode)) { in ext2_iget()
1289 inode->i_op = &ext2_fast_symlink_inode_operations; in ext2_iget()
1290 nd_terminate_link(ei->i_data, inode->i_size, in ext2_iget()
1293 inode->i_op = &ext2_symlink_inode_operations; in ext2_iget()
1294 if (test_opt(inode->i_sb, NOBH)) in ext2_iget()
1295 inode->i_mapping->a_ops = &ext2_nobh_aops; in ext2_iget()
1297 inode->i_mapping->a_ops = &ext2_aops; in ext2_iget()
1300 inode->i_op = &ext2_special_inode_operations; in ext2_iget()
1302 init_special_inode(inode, inode->i_mode, in ext2_iget()
1305 init_special_inode(inode, inode->i_mode, in ext2_iget()
1309 ext2_set_inode_flags(inode); in ext2_iget()
1310 unlock_new_inode(inode); in ext2_iget()
1311 return inode; in ext2_iget()
1314 iget_failed(inode); in ext2_iget()
1318 static int ext2_update_inode(struct inode * inode, int do_sync) in ext2_update_inode() argument
1320 struct ext2_inode_info *ei = EXT2_I(inode); in ext2_update_inode()
1321 struct super_block *sb = inode->i_sb; in ext2_update_inode()
1322 ino_t ino = inode->i_ino; in ext2_update_inode()
1323 uid_t uid = inode->i_uid; in ext2_update_inode()
1324 gid_t gid = inode->i_gid; in ext2_update_inode()
1339 raw_inode->i_mode = cpu_to_le16(inode->i_mode); in ext2_update_inode()
1360 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink); in ext2_update_inode()
1361 raw_inode->i_size = cpu_to_le32(inode->i_size); in ext2_update_inode()
1362 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec); in ext2_update_inode()
1363 raw_inode->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec); in ext2_update_inode()
1364 raw_inode->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec); in ext2_update_inode()
1366 raw_inode->i_blocks = cpu_to_le32(inode->i_blocks); in ext2_update_inode()
1373 if (!S_ISREG(inode->i_mode)) in ext2_update_inode()
1376 raw_inode->i_size_high = cpu_to_le32(inode->i_size >> 32); in ext2_update_inode()
1377 if (inode->i_size > 0x7fffffffULL) { in ext2_update_inode()
1395 raw_inode->i_generation = cpu_to_le32(inode->i_generation); in ext2_update_inode()
1396 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { in ext2_update_inode()
1397 if (old_valid_dev(inode->i_rdev)) { in ext2_update_inode()
1399 cpu_to_le32(old_encode_dev(inode->i_rdev)); in ext2_update_inode()
1404 cpu_to_le32(new_encode_dev(inode->i_rdev)); in ext2_update_inode()
1423 int ext2_write_inode(struct inode *inode, int wait) in ext2_write_inode() argument
1425 return ext2_update_inode(inode, wait); in ext2_write_inode()
1428 int ext2_sync_inode(struct inode *inode) in ext2_sync_inode() argument
1434 return sync_inode(inode, &wbc); in ext2_sync_inode()
1439 struct inode *inode = dentry->d_inode; in ext2_setattr() local
1442 error = inode_change_ok(inode, iattr); in ext2_setattr()
1445 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) || in ext2_setattr()
1446 (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) { in ext2_setattr()
1447 error = DQUOT_TRANSFER(inode, iattr) ? -EDQUOT : 0; in ext2_setattr()
1451 error = inode_setattr(inode, iattr); in ext2_setattr()
1453 error = ext2_acl_chmod(inode); in ext2_setattr()