patch-2.4.25 linux-2.4.25/fs/ext2/inode.c
Next file: linux-2.4.25/fs/ext2/super.c
Previous file: linux-2.4.25/fs/ext2/ialloc.c
Back to the patch index
Back to the overall index
- Lines: 64
- Date:
2004-02-18 05:36:31.000000000 -0800
- Orig file:
linux-2.4.24/fs/ext2/inode.c
- Orig date:
2003-06-13 07:51:37.000000000 -0700
diff -urN linux-2.4.24/fs/ext2/inode.c linux-2.4.25/fs/ext2/inode.c
@@ -35,6 +35,17 @@
MODULE_DESCRIPTION("Second Extended Filesystem");
MODULE_LICENSE("GPL");
+/*
+ * Test whether an inode is a fast symlink.
+ */
+static inline int ext2_inode_is_fast_symlink(struct inode *inode)
+{
+ int ea_blocks = inode->u.ext2_i.i_file_acl ?
+ (inode->i_sb->s_blocksize >> 9) : 0;
+
+ return (S_ISLNK(inode->i_mode) &&
+ inode->i_blocks - ea_blocks == 0);
+}
static int ext2_update_inode(struct inode * inode, int do_sync);
@@ -801,6 +812,8 @@
if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
S_ISLNK(inode->i_mode)))
return;
+ if (ext2_inode_is_fast_symlink(inode))
+ return;
if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
return;
@@ -979,6 +992,7 @@
else
inode->u.ext2_i.i_dir_acl = le32_to_cpu(raw_inode->i_dir_acl);
inode->i_generation = le32_to_cpu(raw_inode->i_generation);
+ inode->u.ext2_i.i_state = 0;
inode->u.ext2_i.i_prealloc_count = 0;
inode->u.ext2_i.i_block_group = block_group;
@@ -1001,7 +1015,7 @@
inode->i_fop = &ext2_dir_operations;
inode->i_mapping->a_ops = &ext2_aops;
} else if (S_ISLNK(inode->i_mode)) {
- if (!inode->i_blocks)
+ if (ext2_inode_is_fast_symlink(inode))
inode->i_op = &ext2_fast_symlink_inode_operations;
else {
inode->i_op = &page_symlink_inode_operations;
@@ -1070,6 +1084,11 @@
offset &= EXT2_BLOCK_SIZE(inode->i_sb) - 1;
raw_inode = (struct ext2_inode *) (bh->b_data + offset);
+ /* For fields not tracked in the in-memory inode,
+ * initialise them to zero for new inodes. */
+ if (inode->u.ext2_i.i_state & EXT2_STATE_NEW)
+ memset(raw_inode, 0, EXT2_SB(inode->i_sb)->s_inode_size);
+
raw_inode->i_mode = cpu_to_le16(inode->i_mode);
if(!(test_opt(inode->i_sb, NO_UID32))) {
raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
@@ -1142,6 +1161,7 @@
err = -EIO;
}
}
+ inode->u.ext2_i.i_state &= ~EXT2_STATE_NEW;
brelse (bh);
return err;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)