dput(dentry); /* this will free the dentry memory */
}
+static void prepare_parent_dentry(struct dentry *dentry, struct inode *inode)
+{
+ atomic_set(&dentry->d_count, 1);
+ dentry->d_vfs_flags = 0;
+ dentry->d_flags = 0;
+ dentry->d_inode = inode;
+ dentry->d_op = NULL;
+ dentry->d_fsdata = NULL;
+ dentry->d_mounted = 0;
+ INIT_LIST_HEAD(&dentry->d_hash);
+ INIT_LIST_HEAD(&dentry->d_lru);
+ INIT_LIST_HEAD(&dentry->d_subdirs);
+ INIT_LIST_HEAD(&dentry->d_alias);
+}
/*
* Return the underlying fs dentry with name in 'dentry' that points
* to the right inode. 'dir' is the clone fs directory to search for
struct dentry *clonefs_lookup(struct inode *dir, struct dentry *dentry)
{
struct inode *cache_dir = NULL;
- struct dentry *cache_dentry = NULL, *tmp = NULL;
+ struct dentry *cache_dentry = NULL;
struct inode *cache_inode;
struct dentry *result;
+ struct dentry tmp;
struct inode *inode;
struct snap_clone_info *clone_sb;
cache_dir = clonefs_get_inode(dir);
if (!cache_dir)
RETURN(ERR_PTR(-ENOENT));
-
- tmp = dget(list_entry(cache_dir->i_dentry.next, struct dentry, d_alias));
-
- cache_dentry = d_alloc(tmp->d_parent, &dentry->d_name);
+ /*FIXME later, we make parent dentry here
+ *there may some problems in lookup
+ */
+ prepare_parent_dentry(&tmp, cache_dir);
+ cache_dentry = d_alloc(&tmp, &dentry->d_name);
if (!cache_dentry) {
iput(cache_dir);
- dput(tmp);
RETURN(ERR_PTR(-ENOENT));
}
/* Lock cache directory inode. */
down(&cache_dir->i_sem);
- dput(tmp);
/*
* Call underlying fs lookup function to set the 'd_inode' pointer
* to the corresponding directory inode.
&open_dentry);
/* tell currentfs_readpage the primary inode number */
open_dentry.d_fsdata = (void*)inode->i_ino;
-
+ page->mapping->host = cache_inode;
/* potemkin case: we are handed a directory inode */
down(&cache_inode->i_sem);
/* XXX - readpage NULL on directories... */
result = cache_inode->i_mapping->a_ops->readpage(&open_file, page);
up(&cache_inode->i_sem);
+ page->mapping->host = inode;
clonefs_restore_snapfile(inode, file, cache_inode, &open_file);
iput(cache_inode);
RETURN(result);
CERROR("Error in currentfs_create, dentry->d_inode is NULL\n");
GOTO(exit, 0);
}
-
- if (S_ISDIR(dentry->d_inode->i_mode))
- dentry->d_inode->i_op = filter_c2udiops(cache->cache_filter);
- else if (S_ISREG(dentry->d_inode->i_mode)) {
- if (!filter_c2cfiops(cache->cache_filter)) {
- filter_setup_file_ops(cache->cache_filter, dentry->d_inode,
- ¤tfs_file_iops, ¤tfs_file_fops,
- ¤tfs_file_aops);
- }
- dentry->d_inode->i_op = filter_c2ufiops(cache->cache_filter);
- }
+ set_filter_ops(cache, dentry->d_inode);
CDEBUG(D_INODE, "inode %lu, i_op %p\n", dentry->d_inode->i_ino, dentry->d_inode->i_op);
snap_debug_device_fail(dir->i_dev, SNAP_OP_CREATE, 3);
init_filter_data(dentry->d_inode, 0);
if (filter_fops) {
if (filter_fops->read)
u_fops->read = filter_fops->read;
+ if (filter_fops->write)
+ u_fops->write = filter_fops->write;
}
if (filter_aops) {
if (filter_aops->readpage)
/* first find if there are indirected at the clone_index */
redirected = snapops->get_indirect(cache_inode, NULL,
- clone_info->clone_index);
+ clone_info->clone_index);
/* if not found, get the FIRST index after this and before NOW */
/* XXX fix this later, now use tbl_count, not NOW */
if (!redirected) {
int index;
+
+ memset(my_table, 0, sizeof(my_table));
clone_slot = snap_index2slot(table, clone_info->clone_index);
for (slot = table->tbl_count-1; slot >= clone_slot; slot --) {
- my_table[slot-clone_slot+1] = table->snap_items[slot].index;
+ my_table[slot - clone_slot + 1] = table->snap_items[slot].index;
}
- index = table->tbl_count - clone_slot + 1;
+ index = table->tbl_count - clone_slot;
redirected = snapops->get_indirect(cache_inode, my_table, index);
}
if (!disk_snap_table)
GOTO(exit, rc = -ENOMEM);
disk_snap_table->magic = cpu_to_le32((__u32)DISK_SNAP_TABLE_MAGIC);
- disk_snap_table->count = cpu_to_le32((__u32)table->tbl_count) - 1;
- disk_snap_table->generation = cpu_to_le32((__u32)table->generation);
+ disk_snap_table->count = cpu_to_le32((__u32)table->tbl_count);
+ disk_snap_table->generation = cpu_to_le32((__u32)table->generation + 1);
memset(&disk_snap_table->snap_items[0], 0,
SNAP_MAX * sizeof(struct snap_disk));