Question about deleting inode / drop inode
I made some modification inode.c for my purpose. I defined myfunc() for my own use
I modified write_inode as following. My purpose is to use a function to determine such inode should pass to lower to lower file system (ext2, vfat, etc) for writing on disk.
static inline void write_inode(struct inode *inode, int sync)
{
if (myfunc() == 0) {
if (inode->i_sb && inode->i_sb->s_op &&
inode->i_sb->s_op->write_inode && !is_bad_inode inode)) {
inode->i_sb->s_op->write_inode(inode, sync); } else {
if (inode->i_sb && inode->i_sb->s_op &&
inode->i_sb->s_op->write_inode && !is_bad_inode(inode)) {
inode->i_sb->s_op->write_inode(inode, sync);
die(inode); }
}
}
static inline void die(inode) {
iput(inode);
}I used iput(inode) in this case. Is it right? I supposed the inode will immediatly deleted after written on disk, and release the block used. But I found that I still can see such file when I press "ls". I also tried to add inode->i_nlink = 0 and atomic_set(&inode->i_count, 0) in die(inode) function before iput(inode), but not success. It may also have input/output error on that file after I reboot system and "ls".
Or any method to drop the inode (do not pass to lower file system layer, just delete it in VFS layer) when myfunc() != 0?
Any one can give suggestion on it? Thanks for help. :D