struct inode *ino = NULL;
struct datablock *b = NULL;
struct inode *inodefile;
+ struct sb_key *k;
int err = 0;
BUG_ON(inum == NO_INO);
- if (sb->s_root)
- inodefile = LAFSI(sb->s_root->d_inode)->filesys;
- else {
- /* FIXME always use this branch?
- * FIXME is this OK for all sub-filesystems?
- */
- inodefile = fs_from_sb(sb)->ss[0].root;
- }
+ k = sb->s_fs_info;
+ inodefile = k->root;
if (async) {
/* We cannot afford to block on 'freeing_inode'
return t | tn;
}
+/* s_fs_info points to an allocated sb_key structure */
+struct sb_key {
+ struct inode *root;
+ struct fs *fs;
+};
+
static inline struct fs *fs_from_sb(struct super_block *sb)
{
- struct fs *fs = sb->s_fs_info;
- return fs;
+ struct sb_key *k = sb->s_fs_info;
+ return k->fs;
}
static inline struct fs *fs_from_inode(struct inode *ino)
struct dentry *de;
int err;
int d;
+ struct sb_key *k = kmalloc(sizeof(*k), GFP_KERNEL);
fs->rolled = 0;
fs->ss[0].root = root = iget_locked(fs->prime_sb, 0);
+ k->root = root;
+ k->fs = fs;
+ fs->prime_sb->s_fs_info = k;
err = -ENOMEM;
b = lafs_get_block(root, 0, NULL, GFP_KERNEL, MKREF(mount));
#include "lafs.h"
#include <linux/namei.h>
#include <linux/crc32.h>
+#include <linux/slab.h>
/*
* Mounting a snapshot is very different from mounting a new
for (s = 1; s < fs->maxsnapshot; s++) {
struct datablock *b;
struct inode *rootdir;
+ struct sb_key *k;
if (fs->ss[s].root_addr == 0)
continue;
if (fs->ss[s].root) {
if (IS_ERR(sb))
return PTR_ERR(sb);
sb->s_flags = flags | MS_RDONLY;
- sb->s_fs_info = fs;
- /* FIXME Inc refcount here?? */
fs->ss[s].root = iget_locked(sb, 1);
+ k = kmalloc(sizeof(*k), GFP_KERNEL);
+ /* FIXME Inc refcount here?? */
+ k->fs = fs;
+ k->root = fs->ss[s].root;
+ sb->s_fs_info = k;
b = lafs_get_block(fs->ss[s].root, 0, NULL, GFP_KERNEL,
MKREF(snap));
b->b.physaddr = fs->ss[s].root_addr;
printk("Generic_shutdown_super being called....\n");
generic_shutdown_super(sb);
+ kfree(sb->s_fs_info);
printk("Generic_shutdown_super called\n");
deactivate_super(fs->prime_sb);
}
fs->prime_sb = sget(&lafs_fs_type, NULL, set_anon_super, NULL);
if (!fs->prime_sb)
goto abort;
- fs->prime_sb->s_fs_info = fs;
fs->prime_sb->s_blocksize = 1 << op->blockbits;
fs->prime_sb->s_blocksize_bits = op->blockbits;
fs->prime_sb->s_op = &lafs_sops;
kfree(fs->devs);
lafs_segtrack_free(fs->segtrack);
kfree(fs->scan.free_usages);
+ kfree(fs->prime_sb->s_fs_info);
kfree(fs);
}