Discussion:
questions
Robert Rappaport
2009-01-22 23:21:08 UTC
Permalink
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
Zachary N. J. Peterson
2009-01-23 20:07:30 UTC
Permalink
Yup. That's a good solution too, so long as set_aops is called in the
right place. dup_inode and fake_inode were based on read_inode, which
is why they look like that. Just out of curiosity, how did you get an
ext3_dup_inode? It should be ext3cow_dup_inode.

-Zachary

---
Zachary N. J. Peterson
Assistant Research Scientist
The Johns Hopkins University

zachary-***@public.gmane.org
http://znjp.com
Post by Robert Rappaport
A question about the code in two routines. In both ext3_dup_inode()
inode->i_op
inode->i_fop
inode->i_mapping->a_ops
/* 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
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
_______________________________________________
ext3cow-devel mailing list
http://hssl.cs.jhu.edu/cgi-bin/mailman/listinfo/ext3cow-devel
Loading...