diff options
Diffstat (limited to 'fs/affs/super.c')
| -rw-r--r-- | fs/affs/super.c | 111 | 
1 files changed, 53 insertions, 58 deletions
diff --git a/fs/affs/super.c b/fs/affs/super.c index 45161a832bb..51f1a95bff7 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c @@ -46,14 +46,9 @@ static void  affs_put_super(struct super_block *sb)  {  	struct affs_sb_info *sbi = AFFS_SB(sb); -	pr_debug("AFFS: put_super()\n"); +	pr_debug("%s()\n", __func__);  	cancel_delayed_work_sync(&sbi->sb_work); -	kfree(sbi->s_prefix); -	affs_free_bitmap(sb); -	affs_brelse(sbi->s_root_bh); -	kfree(sbi); -	sb->s_fs_info = NULL;  }  static int @@ -133,7 +128,7 @@ static void init_once(void *foo)  	inode_init_once(&ei->vfs_inode);  } -static int init_inodecache(void) +static int __init init_inodecache(void)  {  	affs_inode_cachep = kmem_cache_create("affs_inode_cache",  					     sizeof(struct affs_inode_info), @@ -168,7 +163,7 @@ static const struct super_operations affs_sops = {  };  enum { -	Opt_bs, Opt_mode, Opt_mufs, Opt_prefix, Opt_protect, +	Opt_bs, Opt_mode, Opt_mufs, Opt_notruncate, Opt_prefix, Opt_protect,  	Opt_reserved, Opt_root, Opt_setgid, Opt_setuid,  	Opt_verbose, Opt_volume, Opt_ignore, Opt_err,  }; @@ -177,6 +172,7 @@ static const match_table_t tokens = {  	{Opt_bs, "bs=%u"},  	{Opt_mode, "mode=%o"},  	{Opt_mufs, "mufs"}, +	{Opt_notruncate, "nofilenametruncate"},  	{Opt_prefix, "prefix=%s"},  	{Opt_protect, "protect"},  	{Opt_reserved, "reserved=%u"}, @@ -224,7 +220,7 @@ parse_options(char *options, kuid_t *uid, kgid_t *gid, int *mode, int *reserved,  				return 0;  			if (n != 512 && n != 1024 && n != 2048  			    && n != 4096) { -				printk ("AFFS: Invalid blocksize (512, 1024, 2048, 4096 allowed)\n"); +				pr_warn("Invalid blocksize (512, 1024, 2048, 4096 allowed)\n");  				return 0;  			}  			*blocksize = n; @@ -238,6 +234,9 @@ parse_options(char *options, kuid_t *uid, kgid_t *gid, int *mode, int *reserved,  		case Opt_mufs:  			*mount_opts |= SF_MUFS;  			break; +		case Opt_notruncate: +			*mount_opts |= SF_NO_TRUNCATE; +			break;  		case Opt_prefix:  			*prefix = match_strdup(&args[0]);  			if (!*prefix) @@ -286,8 +285,8 @@ parse_options(char *options, kuid_t *uid, kgid_t *gid, int *mode, int *reserved,  		 	/* Silently ignore the quota options */  			break;  		default: -			printk("AFFS: Unrecognized mount option \"%s\" " -					"or missing value\n", p); +			pr_warn("Unrecognized mount option \"%s\" or missing value\n", +				p);  			return 0;  		}  	} @@ -316,11 +315,11 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)  	unsigned long		 mount_flags;  	int			 tmp_flags;	/* fix remount prototype... */  	u8			 sig[4]; -	int			 ret = -EINVAL; +	int			 ret;  	save_mount_options(sb, data); -	pr_debug("AFFS: read_super(%s)\n",data ? (const char *)data : "no options"); +	pr_debug("read_super(%s)\n", data ? (const char *)data : "no options");  	sb->s_magic             = AFFS_SUPER_MAGIC;  	sb->s_op                = &affs_sops; @@ -340,9 +339,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)  	if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block,  				&blocksize,&sbi->s_prefix,  				sbi->s_volume, &mount_flags)) { -		printk(KERN_ERR "AFFS: Error parsing options\n"); -		kfree(sbi->s_prefix); -		kfree(sbi); +		pr_err("Error parsing options\n");  		return -EINVAL;  	}  	/* N.B. after this point s_prefix must be released */ @@ -359,7 +356,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)  	 */  	size = sb->s_bdev->bd_inode->i_size >> 9; -	pr_debug("AFFS: initial blocksize=%d, #blocks=%d\n", 512, size); +	pr_debug("initial blocksize=%d, #blocks=%d\n", 512, size);  	affs_set_blocksize(sb, PAGE_SIZE);  	/* Try to find root block. Its location depends on the block size. */ @@ -374,7 +371,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)  		sbi->s_root_block = root_block;  		if (root_block < 0)  			sbi->s_root_block = (reserved + size - 1) / 2; -		pr_debug("AFFS: setting blocksize to %d\n", blocksize); +		pr_debug("setting blocksize to %d\n", blocksize);  		affs_set_blocksize(sb, blocksize);  		sbi->s_partition_size = size; @@ -389,7 +386,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)  		 * block behind the calculated one. So we check this one, too.  		 */  		for (num_bm = 0; num_bm < 2; num_bm++) { -			pr_debug("AFFS: Dev %s, trying root=%u, bs=%d, " +			pr_debug("Dev %s, trying root=%u, bs=%d, "  				"size=%d, reserved=%d\n",  				sb->s_id,  				sbi->s_root_block + num_bm, @@ -410,19 +407,20 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)  		}  	}  	if (!silent) -		printk(KERN_ERR "AFFS: No valid root block on device %s\n", -			sb->s_id); -	goto out_error; +		pr_err("No valid root block on device %s\n", sb->s_id); +	return -EINVAL;  	/* N.B. after this point bh must be released */  got_root: +	/* Keep super block in cache */ +	sbi->s_root_bh = root_bh;  	root_block = sbi->s_root_block;  	/* Find out which kind of FS we have */  	boot_bh = sb_bread(sb, 0);  	if (!boot_bh) { -		printk(KERN_ERR "AFFS: Cannot read boot block\n"); -		goto out_error; +		pr_err("Cannot read boot block\n"); +		return -EINVAL;  	}  	memcpy(sig, boot_bh->b_data, 4);  	brelse(boot_bh); @@ -434,8 +432,7 @@ got_root:  	 */  	if ((chksum == FS_DCFFS || chksum == MUFS_DCFFS || chksum == FS_DCOFS  	     || chksum == MUFS_DCOFS) && !(sb->s_flags & MS_RDONLY)) { -		printk(KERN_NOTICE "AFFS: Dircache FS - mounting %s read only\n", -			sb->s_id); +		pr_notice("Dircache FS - mounting %s read only\n", sb->s_id);  		sb->s_flags |= MS_RDONLY;  	}  	switch (chksum) { @@ -469,14 +466,14 @@ got_root:  			sb->s_flags |= MS_NOEXEC;  			break;  		default: -			printk(KERN_ERR "AFFS: Unknown filesystem on device %s: %08X\n", -				sb->s_id, chksum); -			goto out_error; +			pr_err("Unknown filesystem on device %s: %08X\n", +			       sb->s_id, chksum); +			return -EINVAL;  	}  	if (mount_flags & SF_VERBOSE) {  		u8 len = AFFS_ROOT_TAIL(sb, root_bh)->disk_name[0]; -		printk(KERN_NOTICE "AFFS: Mounting volume \"%.*s\": Type=%.3s\\%c, Blocksize=%d\n", +		pr_notice("Mounting volume \"%.*s\": Type=%.3s\\%c, Blocksize=%d\n",  			len > 31 ? 31 : len,  			AFFS_ROOT_TAIL(sb, root_bh)->disk_name + 1,  			sig, sig[3] + '0', blocksize); @@ -488,22 +485,17 @@ got_root:  	if (sbi->s_flags & SF_OFS)  		sbi->s_data_blksize -= 24; -	/* Keep super block in cache */ -	sbi->s_root_bh = root_bh; -	/* N.B. after this point s_root_bh must be released */ -  	tmp_flags = sb->s_flags; -	if (affs_init_bitmap(sb, &tmp_flags)) -		goto out_error; +	ret = affs_init_bitmap(sb, &tmp_flags); +	if (ret) +		return ret;  	sb->s_flags = tmp_flags;  	/* set up enough so that it can read an inode */  	root_inode = affs_iget(sb, root_block); -	if (IS_ERR(root_inode)) { -		ret = PTR_ERR(root_inode); -		goto out_error; -	} +	if (IS_ERR(root_inode)) +		return PTR_ERR(root_inode);  	if (AFFS_SB(sb)->s_flags & SF_INTL)  		sb->s_d_op = &affs_intl_dentry_operations; @@ -512,23 +504,12 @@ got_root:  	sb->s_root = d_make_root(root_inode);  	if (!sb->s_root) { -		printk(KERN_ERR "AFFS: Get root inode failed\n"); -		goto out_error; +		pr_err("AFFS: Get root inode failed\n"); +		return -ENOMEM;  	} -	pr_debug("AFFS: s_flags=%lX\n",sb->s_flags); +	pr_debug("s_flags=%lX\n", sb->s_flags);  	return 0; - -	/* -	 * Begin the cascaded cleanup ... -	 */ -out_error: -	kfree(sbi->s_bitmap); -	affs_brelse(root_bh); -	kfree(sbi->s_prefix); -	kfree(sbi); -	sb->s_fs_info = NULL; -	return ret;  }  static int @@ -547,8 +528,9 @@ affs_remount(struct super_block *sb, int *flags, char *data)  	char			 volume[32];  	char			*prefix = NULL; -	pr_debug("AFFS: remount(flags=0x%x,opts=\"%s\")\n",*flags,data); +	pr_debug("%s(flags=0x%x,opts=\"%s\")\n", __func__, *flags, data); +	sync_filesystem(sb);  	*flags |= MS_NODIRATIME;  	memcpy(volume, sbi->s_volume, 32); @@ -594,8 +576,9 @@ affs_statfs(struct dentry *dentry, struct kstatfs *buf)  	int		 free;  	u64		 id = huge_encode_dev(sb->s_bdev->bd_dev); -	pr_debug("AFFS: statfs() partsize=%d, reserved=%d\n",AFFS_SB(sb)->s_partition_size, -	     AFFS_SB(sb)->s_reserved); +	pr_debug("%s() partsize=%d, reserved=%d\n", +		 __func__, AFFS_SB(sb)->s_partition_size, +		 AFFS_SB(sb)->s_reserved);  	free          = affs_count_free_blocks(sb);  	buf->f_type    = AFFS_SUPER_MAGIC; @@ -615,11 +598,23 @@ static struct dentry *affs_mount(struct file_system_type *fs_type,  	return mount_bdev(fs_type, flags, dev_name, data, affs_fill_super);  } +static void affs_kill_sb(struct super_block *sb) +{ +	struct affs_sb_info *sbi = AFFS_SB(sb); +	kill_block_super(sb); +	if (sbi) { +		affs_free_bitmap(sb); +		affs_brelse(sbi->s_root_bh); +		kfree(sbi->s_prefix); +		kfree(sbi); +	} +} +  static struct file_system_type affs_fs_type = {  	.owner		= THIS_MODULE,  	.name		= "affs",  	.mount		= affs_mount, -	.kill_sb	= kill_block_super, +	.kill_sb	= affs_kill_sb,  	.fs_flags	= FS_REQUIRES_DEV,  };  MODULE_ALIAS_FS("affs");  | 
