KVM: MMU: invalidate and flush on spte small->large page size change
[safe/jmp/linux-2.6] / fs / adfs / super.c
index 252abda..4a3af70 100644 (file)
@@ -8,35 +8,28 @@
  * published by the Free Software Foundation.
  */
 #include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/adfs_fs.h>
-#include <linux/slab.h>
-#include <linux/time.h>
-#include <linux/stat.h>
-#include <linux/string.h>
 #include <linux/init.h>
 #include <linux/buffer_head.h>
-#include <linux/vfs.h>
 #include <linux/parser.h>
-#include <linux/bitops.h>
-
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-#include <stdarg.h>
-
+#include <linux/mount.h>
+#include <linux/seq_file.h>
+#include <linux/slab.h>
+#include <linux/smp_lock.h>
+#include <linux/statfs.h>
 #include "adfs.h"
 #include "dir_f.h"
 #include "dir_fplus.h"
 
+#define ADFS_DEFAULT_OWNER_MASK S_IRWXU
+#define ADFS_DEFAULT_OTHER_MASK (S_IRWXG | S_IRWXO)
+
 void __adfs_error(struct super_block *sb, const char *function, const char *fmt, ...)
 {
        char error_buf[128];
        va_list args;
 
        va_start(args, fmt);
-       vsprintf(error_buf, fmt, args);
+       vsnprintf(error_buf, sizeof(error_buf), fmt, args);
        va_end(args);
 
        printk(KERN_CRIT "ADFS-fs error (device %s)%s%s: %s\n",
@@ -127,16 +120,36 @@ static void adfs_put_super(struct super_block *sb)
        int i;
        struct adfs_sb_info *asb = ADFS_SB(sb);
 
+       lock_kernel();
+
        for (i = 0; i < asb->s_map_size; i++)
                brelse(asb->s_map[i].dm_bh);
        kfree(asb->s_map);
        kfree(asb);
        sb->s_fs_info = NULL;
+
+       unlock_kernel();
+}
+
+static int adfs_show_options(struct seq_file *seq, struct vfsmount *mnt)
+{
+       struct adfs_sb_info *asb = ADFS_SB(mnt->mnt_sb);
+
+       if (asb->s_uid != 0)
+               seq_printf(seq, ",uid=%u", asb->s_uid);
+       if (asb->s_gid != 0)
+               seq_printf(seq, ",gid=%u", asb->s_gid);
+       if (asb->s_owner_mask != ADFS_DEFAULT_OWNER_MASK)
+               seq_printf(seq, ",ownmask=%o", asb->s_owner_mask);
+       if (asb->s_other_mask != ADFS_DEFAULT_OTHER_MASK)
+               seq_printf(seq, ",othmask=%o", asb->s_other_mask);
+
+       return 0;
 }
 
 enum {Opt_uid, Opt_gid, Opt_ownmask, Opt_othmask, Opt_err};
 
-static match_table_t tokens = {
+static const match_table_t tokens = {
        {Opt_uid, "uid=%u"},
        {Opt_gid, "gid=%u"},
        {Opt_ownmask, "ownmask=%o"},
@@ -196,28 +209,32 @@ static int adfs_remount(struct super_block *sb, int *flags, char *data)
        return parse_options(sb, data);
 }
 
-static int adfs_statfs(struct super_block *sb, struct kstatfs *buf)
+static int adfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
-       struct adfs_sb_info *asb = ADFS_SB(sb);
+       struct super_block *sb = dentry->d_sb;
+       struct adfs_sb_info *sbi = ADFS_SB(sb);
+       u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
 
        buf->f_type    = ADFS_SUPER_MAGIC;
-       buf->f_namelen = asb->s_namelen;
+       buf->f_namelen = sbi->s_namelen;
        buf->f_bsize   = sb->s_blocksize;
-       buf->f_blocks  = asb->s_size;
-       buf->f_files   = asb->s_ids_per_zone * asb->s_map_size;
+       buf->f_blocks  = sbi->s_size;
+       buf->f_files   = sbi->s_ids_per_zone * sbi->s_map_size;
        buf->f_bavail  =
        buf->f_bfree   = adfs_map_free(sb);
        buf->f_ffree   = (long)(buf->f_bfree * buf->f_files) / (long)buf->f_blocks;
+       buf->f_fsid.val[0] = (u32)id;
+       buf->f_fsid.val[1] = (u32)(id >> 32);
 
        return 0;
 }
 
-static kmem_cache_t *adfs_inode_cachep;
+static struct kmem_cache *adfs_inode_cachep;
 
 static struct inode *adfs_alloc_inode(struct super_block *sb)
 {
        struct adfs_inode_info *ei;
-       ei = (struct adfs_inode_info *)kmem_cache_alloc(adfs_inode_cachep, SLAB_KERNEL);
+       ei = (struct adfs_inode_info *)kmem_cache_alloc(adfs_inode_cachep, GFP_KERNEL);
        if (!ei)
                return NULL;
        return &ei->vfs_inode;
@@ -228,22 +245,20 @@ static void adfs_destroy_inode(struct inode *inode)
        kmem_cache_free(adfs_inode_cachep, ADFS_I(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void *foo)
 {
        struct adfs_inode_info *ei = (struct adfs_inode_info *) foo;
 
-       if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
-           SLAB_CTOR_CONSTRUCTOR)
-               inode_init_once(&ei->vfs_inode);
+       inode_init_once(&ei->vfs_inode);
 }
+
 static int init_inodecache(void)
 {
        adfs_inode_cachep = kmem_cache_create("adfs_inode_cache",
                                             sizeof(struct adfs_inode_info),
                                             0, (SLAB_RECLAIM_ACCOUNT|
                                                SLAB_MEM_SPREAD),
-                                            init_once, NULL);
+                                            init_once);
        if (adfs_inode_cachep == NULL)
                return -ENOMEM;
        return 0;
@@ -251,17 +266,17 @@ static int init_inodecache(void)
 
 static void destroy_inodecache(void)
 {
-       if (kmem_cache_destroy(adfs_inode_cachep))
-               printk(KERN_INFO "adfs_inode_cache: not all structures were freed\n");
+       kmem_cache_destroy(adfs_inode_cachep);
 }
 
-static struct super_operations adfs_sops = {
+static const struct super_operations adfs_sops = {
        .alloc_inode    = adfs_alloc_inode,
        .destroy_inode  = adfs_destroy_inode,
        .write_inode    = adfs_write_inode,
        .put_super      = adfs_put_super,
        .statfs         = adfs_statfs,
        .remount_fs     = adfs_remount,
+       .show_options   = adfs_show_options,
 };
 
 static struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_discrecord *dr)
@@ -308,7 +323,7 @@ static struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_di
        if (adfs_checkmap(sb, dm))
                return dm;
 
-       adfs_error(sb, NULL, "map corrupted");
+       adfs_error(sb, "map corrupted");
 
 error_free:
        while (--zone >= 0)
@@ -339,17 +354,16 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
 
        sb->s_flags |= MS_NODIRATIME;
 
-       asb = kmalloc(sizeof(*asb), GFP_KERNEL);
+       asb = kzalloc(sizeof(*asb), GFP_KERNEL);
        if (!asb)
                return -ENOMEM;
        sb->s_fs_info = asb;
-       memset(asb, 0, sizeof(*asb));
 
        /* set default options */
        asb->s_uid = 0;
        asb->s_gid = 0;
-       asb->s_owner_mask = S_IRWXU;
-       asb->s_other_mask = S_IRWXG | S_IRWXO;
+       asb->s_owner_mask = ADFS_DEFAULT_OWNER_MASK;
+       asb->s_other_mask = ADFS_DEFAULT_OTHER_MASK;
 
        if (parse_options(sb, data))
                goto error;
@@ -470,10 +484,11 @@ error:
        return -EINVAL;
 }
 
-static struct super_block *adfs_get_sb(struct file_system_type *fs_type,
-       int flags, const char *dev_name, void *data)
+static int adfs_get_sb(struct file_system_type *fs_type,
+       int flags, const char *dev_name, void *data, struct vfsmount *mnt)
 {
-       return get_sb_bdev(fs_type, flags, dev_name, data, adfs_fill_super);
+       return get_sb_bdev(fs_type, flags, dev_name, data, adfs_fill_super,
+                          mnt);
 }
 
 static struct file_system_type adfs_fs_type = {
@@ -507,3 +522,4 @@ static void __exit exit_adfs_fs(void)
 
 module_init(init_adfs_fs)
 module_exit(exit_adfs_fs)
+MODULE_LICENSE("GPL");