Robert Rappaport
2009-01-22 23:21:08 UTC
A question about the code in two routines. In both ext3_dup_inode()
and ext3_fake_inode(), when initializing the following fields:
inode->i_op
inode->i_fop
inode->i_mapping->a_ops
the code goes through the following gyrations:
/* Make sure we get the right operations */
if (S_ISREG(cow_inode->i_mode)) {
cow_inode->i_op = &ext3_file_inode_operations;
cow_inode->i_fop = &ext3_file_operations;
ext3_set_aops(cow_inode);
} else if (S_ISDIR(cow_inode->i_mode)) {
cow_inode->i_op = &ext3_dir_inode_operations;
cow_inode->i_fop = &ext3_dir_operations;
} else if (S_ISLNK(cow_inode->i_mode)) {
//if (ext3_inode_is_fast_symlink(cow_inode))
if((S_ISLNK(cow_inode->i_mode) && cow_inode->i_blocks -
(EXT3_I(cow_inode)->i_file_acl ?
(cow_inode->i_sb->s_blocksize >> 9) : 0)))
cow_inode->i_op = &ext3_fast_symlink_inode_operations;
else {
cow_inode->i_op = &ext3_symlink_inode_operations;
ext3_set_aops(cow_inode);
}
} else {
cow_inode->i_op = &ext3_special_inode_operations;
}
My question is why don't you simply copy the relevant fields from the
original inode? For example:
cow_inode->i_op = inode->i_op;
cow_inode->i_fop = inode->i_fop;
cow_inode->i_mapping->a_ops = inode->i_mapping->a_ops;
Thanks.
- Robert Rappaport
and ext3_fake_inode(), when initializing the following fields:
inode->i_op
inode->i_fop
inode->i_mapping->a_ops
the code goes through the following gyrations:
/* Make sure we get the right operations */
if (S_ISREG(cow_inode->i_mode)) {
cow_inode->i_op = &ext3_file_inode_operations;
cow_inode->i_fop = &ext3_file_operations;
ext3_set_aops(cow_inode);
} else if (S_ISDIR(cow_inode->i_mode)) {
cow_inode->i_op = &ext3_dir_inode_operations;
cow_inode->i_fop = &ext3_dir_operations;
} else if (S_ISLNK(cow_inode->i_mode)) {
//if (ext3_inode_is_fast_symlink(cow_inode))
if((S_ISLNK(cow_inode->i_mode) && cow_inode->i_blocks -
(EXT3_I(cow_inode)->i_file_acl ?
(cow_inode->i_sb->s_blocksize >> 9) : 0)))
cow_inode->i_op = &ext3_fast_symlink_inode_operations;
else {
cow_inode->i_op = &ext3_symlink_inode_operations;
ext3_set_aops(cow_inode);
}
} else {
cow_inode->i_op = &ext3_special_inode_operations;
}
My question is why don't you simply copy the relevant fields from the
original inode? For example:
cow_inode->i_op = inode->i_op;
cow_inode->i_fop = inode->i_fop;
cow_inode->i_mapping->a_ops = inode->i_mapping->a_ops;
Thanks.
- Robert Rappaport