Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  *  linux/fs/ext2/super.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  * Copyright (C) 1992, 1993, 1994, 1995
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  * Remy Card (card@masi.ibp.fr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  * Laboratoire MASI - Institut Blaise Pascal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  * Universite Pierre et Marie Curie (Paris VI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10)  *  from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12)  *  linux/fs/minix/inode.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14)  *  Copyright (C) 1991, 1992  Linus Torvalds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16)  *  Big-endian to little-endian byte-swapping/bitmaps by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17)  *        David S. Miller (davem@caip.rutgers.edu), 1995
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) #include <linux/parser.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) #include <linux/random.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) #include <linux/buffer_head.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) #include <linux/exportfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) #include <linux/vfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) #include <linux/mount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) #include <linux/log2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) #include <linux/quotaops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) #include <linux/dax.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) #include <linux/iversion.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) #include "ext2.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) #include "xattr.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) #include "acl.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) static void ext2_write_super(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) static int ext2_remount (struct super_block * sb, int * flags, char * data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) static int ext2_sync_fs(struct super_block *sb, int wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) static int ext2_freeze(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) static int ext2_unfreeze(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) void ext2_error(struct super_block *sb, const char *function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) 		const char *fmt, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 	struct va_format vaf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) 	va_list args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) 	struct ext2_sb_info *sbi = EXT2_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) 	struct ext2_super_block *es = sbi->s_es;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) 	if (!sb_rdonly(sb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 		spin_lock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 		sbi->s_mount_state |= EXT2_ERROR_FS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) 		es->s_state |= cpu_to_le16(EXT2_ERROR_FS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 		spin_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 		ext2_sync_super(sb, es, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) 	va_start(args, fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) 	vaf.fmt = fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 	vaf.va = &args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) 	printk(KERN_CRIT "EXT2-fs (%s): error: %s: %pV\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 	       sb->s_id, function, &vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 	va_end(args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) 	if (test_opt(sb, ERRORS_PANIC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 		panic("EXT2-fs: panic from previous error\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) 	if (!sb_rdonly(sb) && test_opt(sb, ERRORS_RO)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 		ext2_msg(sb, KERN_CRIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 			     "error: remounting filesystem read-only");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 		sb->s_flags |= SB_RDONLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) void ext2_msg(struct super_block *sb, const char *prefix,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) 		const char *fmt, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 	struct va_format vaf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 	va_list args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) 	va_start(args, fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) 	vaf.fmt = fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 	vaf.va = &args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 	printk("%sEXT2-fs (%s): %pV\n", prefix, sb->s_id, &vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 	va_end(args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101)  * This must be called with sbi->s_lock held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) void ext2_update_dynamic_rev(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 	struct ext2_super_block *es = EXT2_SB(sb)->s_es;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 	if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 	ext2_msg(sb, KERN_WARNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 		     "warning: updating to rev %d because of "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 		     "new feature flag, running e2fsck is recommended",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 		     EXT2_DYNAMIC_REV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 	es->s_first_ino = cpu_to_le32(EXT2_GOOD_OLD_FIRST_INO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 	es->s_inode_size = cpu_to_le16(EXT2_GOOD_OLD_INODE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 	es->s_rev_level = cpu_to_le32(EXT2_DYNAMIC_REV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 	/* leave es->s_feature_*compat flags alone */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 	/* es->s_uuid will be set by e2fsck if empty */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 	 * The rest of the superblock fields should be zero, and if not it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 	 * means they are likely already in use, so leave them alone.  We
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 	 * can leave it up to e2fsck to clean up any inconsistencies there.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) #ifdef CONFIG_QUOTA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) static int ext2_quota_off(struct super_block *sb, int type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) static void ext2_quota_off_umount(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 	int type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 	for (type = 0; type < MAXQUOTAS; type++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 		ext2_quota_off(sb, type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) static inline void ext2_quota_off_umount(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) static void ext2_put_super (struct super_block * sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 	int db_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 	struct ext2_sb_info *sbi = EXT2_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 	ext2_quota_off_umount(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 	ext2_xattr_destroy_cache(sbi->s_ea_block_cache);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 	sbi->s_ea_block_cache = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 	if (!sb_rdonly(sb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 		struct ext2_super_block *es = sbi->s_es;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 		spin_lock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 		es->s_state = cpu_to_le16(sbi->s_mount_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 		spin_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 		ext2_sync_super(sb, es, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 	db_count = sbi->s_gdb_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 	for (i = 0; i < db_count; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 		brelse(sbi->s_group_desc[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 	kfree(sbi->s_group_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 	kfree(sbi->s_debts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 	percpu_counter_destroy(&sbi->s_freeblocks_counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 	percpu_counter_destroy(&sbi->s_freeinodes_counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 	percpu_counter_destroy(&sbi->s_dirs_counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 	brelse (sbi->s_sbh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 	sb->s_fs_info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 	kfree(sbi->s_blockgroup_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 	fs_put_dax(sbi->s_daxdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 	kfree(sbi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) static struct kmem_cache * ext2_inode_cachep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) static struct inode *ext2_alloc_inode(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 	struct ext2_inode_info *ei;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 	ei = kmem_cache_alloc(ext2_inode_cachep, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	if (!ei)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 	ei->i_block_alloc_info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 	inode_set_iversion(&ei->vfs_inode, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) #ifdef CONFIG_QUOTA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 	memset(&ei->i_dquot, 0, sizeof(ei->i_dquot));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 	return &ei->vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) static void ext2_free_in_core_inode(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 	kmem_cache_free(ext2_inode_cachep, EXT2_I(inode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) static void init_once(void *foo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 	struct ext2_inode_info *ei = (struct ext2_inode_info *) foo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 	rwlock_init(&ei->i_meta_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) #ifdef CONFIG_EXT2_FS_XATTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 	init_rwsem(&ei->xattr_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 	mutex_init(&ei->truncate_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) #ifdef CONFIG_FS_DAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 	init_rwsem(&ei->dax_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 	inode_init_once(&ei->vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) static int __init init_inodecache(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 	ext2_inode_cachep = kmem_cache_create_usercopy("ext2_inode_cache",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 				sizeof(struct ext2_inode_info), 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 				(SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 					SLAB_ACCOUNT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 				offsetof(struct ext2_inode_info, i_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 				sizeof_field(struct ext2_inode_info, i_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 				init_once);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 	if (ext2_inode_cachep == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) static void destroy_inodecache(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 	 * Make sure all delayed rcu free inodes are flushed before we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 	 * destroy cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 	rcu_barrier();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 	kmem_cache_destroy(ext2_inode_cachep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) static int ext2_show_options(struct seq_file *seq, struct dentry *root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 	struct super_block *sb = root->d_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 	struct ext2_sb_info *sbi = EXT2_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 	struct ext2_super_block *es = sbi->s_es;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 	unsigned long def_mount_opts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 	spin_lock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 	def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 	if (sbi->s_sb_block != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 		seq_printf(seq, ",sb=%lu", sbi->s_sb_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	if (test_opt(sb, MINIX_DF))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 		seq_puts(seq, ",minixdf");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	if (test_opt(sb, GRPID))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 		seq_puts(seq, ",grpid");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	if (!test_opt(sb, GRPID) && (def_mount_opts & EXT2_DEFM_BSDGROUPS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 		seq_puts(seq, ",nogrpid");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 	if (!uid_eq(sbi->s_resuid, make_kuid(&init_user_ns, EXT2_DEF_RESUID)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 	    le16_to_cpu(es->s_def_resuid) != EXT2_DEF_RESUID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 		seq_printf(seq, ",resuid=%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 				from_kuid_munged(&init_user_ns, sbi->s_resuid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 	if (!gid_eq(sbi->s_resgid, make_kgid(&init_user_ns, EXT2_DEF_RESGID)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 	    le16_to_cpu(es->s_def_resgid) != EXT2_DEF_RESGID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 		seq_printf(seq, ",resgid=%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 				from_kgid_munged(&init_user_ns, sbi->s_resgid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 	if (test_opt(sb, ERRORS_RO)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 		int def_errors = le16_to_cpu(es->s_errors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 		if (def_errors == EXT2_ERRORS_PANIC ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 		    def_errors == EXT2_ERRORS_CONTINUE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 			seq_puts(seq, ",errors=remount-ro");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 	if (test_opt(sb, ERRORS_CONT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 		seq_puts(seq, ",errors=continue");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 	if (test_opt(sb, ERRORS_PANIC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 		seq_puts(seq, ",errors=panic");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 	if (test_opt(sb, NO_UID32))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 		seq_puts(seq, ",nouid32");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 	if (test_opt(sb, DEBUG))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 		seq_puts(seq, ",debug");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 	if (test_opt(sb, OLDALLOC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 		seq_puts(seq, ",oldalloc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) #ifdef CONFIG_EXT2_FS_XATTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 	if (test_opt(sb, XATTR_USER))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 		seq_puts(seq, ",user_xattr");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 	if (!test_opt(sb, XATTR_USER) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 	    (def_mount_opts & EXT2_DEFM_XATTR_USER)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 		seq_puts(seq, ",nouser_xattr");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) #ifdef CONFIG_EXT2_FS_POSIX_ACL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 	if (test_opt(sb, POSIX_ACL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 		seq_puts(seq, ",acl");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 	if (!test_opt(sb, POSIX_ACL) && (def_mount_opts & EXT2_DEFM_ACL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 		seq_puts(seq, ",noacl");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 	if (test_opt(sb, NOBH))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 		seq_puts(seq, ",nobh");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 	if (test_opt(sb, USRQUOTA))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 		seq_puts(seq, ",usrquota");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 	if (test_opt(sb, GRPQUOTA))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 		seq_puts(seq, ",grpquota");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 	if (test_opt(sb, XIP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 		seq_puts(seq, ",xip");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 	if (test_opt(sb, DAX))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 		seq_puts(seq, ",dax");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 	if (!test_opt(sb, RESERVATION))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 		seq_puts(seq, ",noreservation");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 	spin_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) #ifdef CONFIG_QUOTA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data, size_t len, loff_t off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) static ssize_t ext2_quota_write(struct super_block *sb, int type, const char *data, size_t len, loff_t off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) static int ext2_quota_on(struct super_block *sb, int type, int format_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 			 const struct path *path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) static struct dquot **ext2_get_dquots(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 	return EXT2_I(inode)->i_dquot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) static const struct quotactl_ops ext2_quotactl_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 	.quota_on	= ext2_quota_on,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 	.quota_off	= ext2_quota_off,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 	.quota_sync	= dquot_quota_sync,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 	.get_state	= dquot_get_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 	.set_info	= dquot_set_dqinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 	.get_dqblk	= dquot_get_dqblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 	.set_dqblk	= dquot_set_dqblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 	.get_nextdqblk	= dquot_get_next_dqblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) static const struct super_operations ext2_sops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 	.alloc_inode	= ext2_alloc_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 	.free_inode	= ext2_free_in_core_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 	.write_inode	= ext2_write_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 	.evict_inode	= ext2_evict_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 	.put_super	= ext2_put_super,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 	.sync_fs	= ext2_sync_fs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 	.freeze_fs	= ext2_freeze,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 	.unfreeze_fs	= ext2_unfreeze,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 	.statfs		= ext2_statfs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 	.remount_fs	= ext2_remount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 	.show_options	= ext2_show_options,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) #ifdef CONFIG_QUOTA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 	.quota_read	= ext2_quota_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 	.quota_write	= ext2_quota_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 	.get_dquots	= ext2_get_dquots,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) static struct inode *ext2_nfs_get_inode(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 		u64 ino, u32 generation)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 	struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 	if (ino < EXT2_FIRST_INO(sb) && ino != EXT2_ROOT_INO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 		return ERR_PTR(-ESTALE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 	if (ino > le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 		return ERR_PTR(-ESTALE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 	 * ext2_iget isn't quite right if the inode is currently unallocated!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 	 * However ext2_iget currently does appropriate checks to handle stale
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 	 * inodes so everything is OK.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 	inode = ext2_iget(sb, ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 	if (IS_ERR(inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 		return ERR_CAST(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 	if (generation && inode->i_generation != generation) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 		/* we didn't find the right inode.. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 		iput(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 		return ERR_PTR(-ESTALE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 	return inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) static struct dentry *ext2_fh_to_dentry(struct super_block *sb, struct fid *fid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 		int fh_len, int fh_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 	return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 				    ext2_nfs_get_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) static struct dentry *ext2_fh_to_parent(struct super_block *sb, struct fid *fid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 		int fh_len, int fh_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 	return generic_fh_to_parent(sb, fid, fh_len, fh_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 				    ext2_nfs_get_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) static const struct export_operations ext2_export_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 	.fh_to_dentry = ext2_fh_to_dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 	.fh_to_parent = ext2_fh_to_parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 	.get_parent = ext2_get_parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) static unsigned long get_sb_block(void **data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 	unsigned long 	sb_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 	char 		*options = (char *) *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 	if (!options || strncmp(options, "sb=", 3) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 		return 1;	/* Default location */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 	options += 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 	sb_block = simple_strtoul(options, &options, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 	if (*options && *options != ',') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 		printk("EXT2-fs: Invalid sb specification: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 		       (char *) *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 	if (*options == ',')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 		options++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 	*data = (void *) options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 	return sb_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 	Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 	Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 	Opt_err_ro, Opt_nouid32, Opt_debug,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 	Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	Opt_acl, Opt_noacl, Opt_xip, Opt_dax, Opt_ignore, Opt_err, Opt_quota,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 	Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) static const match_table_t tokens = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 	{Opt_bsd_df, "bsddf"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 	{Opt_minix_df, "minixdf"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 	{Opt_grpid, "grpid"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 	{Opt_grpid, "bsdgroups"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 	{Opt_nogrpid, "nogrpid"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 	{Opt_nogrpid, "sysvgroups"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 	{Opt_resgid, "resgid=%u"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 	{Opt_resuid, "resuid=%u"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 	{Opt_sb, "sb=%u"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 	{Opt_err_cont, "errors=continue"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 	{Opt_err_panic, "errors=panic"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 	{Opt_err_ro, "errors=remount-ro"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 	{Opt_nouid32, "nouid32"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 	{Opt_debug, "debug"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 	{Opt_oldalloc, "oldalloc"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 	{Opt_orlov, "orlov"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 	{Opt_nobh, "nobh"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 	{Opt_user_xattr, "user_xattr"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 	{Opt_nouser_xattr, "nouser_xattr"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 	{Opt_acl, "acl"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 	{Opt_noacl, "noacl"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	{Opt_xip, "xip"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 	{Opt_dax, "dax"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 	{Opt_grpquota, "grpquota"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 	{Opt_ignore, "noquota"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 	{Opt_quota, "quota"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 	{Opt_usrquota, "usrquota"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 	{Opt_reservation, "reservation"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 	{Opt_noreservation, "noreservation"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 	{Opt_err, NULL}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) static int parse_options(char *options, struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 			 struct ext2_mount_options *opts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	char *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 	substring_t args[MAX_OPT_ARGS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 	int option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 	kuid_t uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 	kgid_t gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 	if (!options)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 	while ((p = strsep (&options, ",")) != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 		int token;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 		if (!*p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 		token = match_token(p, tokens, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 		switch (token) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 		case Opt_bsd_df:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 			clear_opt (opts->s_mount_opt, MINIX_DF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 		case Opt_minix_df:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 			set_opt (opts->s_mount_opt, MINIX_DF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 		case Opt_grpid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 			set_opt (opts->s_mount_opt, GRPID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 		case Opt_nogrpid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 			clear_opt (opts->s_mount_opt, GRPID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 		case Opt_resuid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 			if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 			uid = make_kuid(current_user_ns(), option);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 			if (!uid_valid(uid)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 				ext2_msg(sb, KERN_ERR, "Invalid uid value %d", option);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 			opts->s_resuid = uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 		case Opt_resgid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 			if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 			gid = make_kgid(current_user_ns(), option);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 			if (!gid_valid(gid)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 				ext2_msg(sb, KERN_ERR, "Invalid gid value %d", option);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 			opts->s_resgid = gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 		case Opt_sb:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 			/* handled by get_sb_block() instead of here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 			/* *sb_block = match_int(&args[0]); */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 		case Opt_err_panic:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 			clear_opt (opts->s_mount_opt, ERRORS_CONT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 			clear_opt (opts->s_mount_opt, ERRORS_RO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 			set_opt (opts->s_mount_opt, ERRORS_PANIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 		case Opt_err_ro:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 			clear_opt (opts->s_mount_opt, ERRORS_CONT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 			clear_opt (opts->s_mount_opt, ERRORS_PANIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 			set_opt (opts->s_mount_opt, ERRORS_RO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 		case Opt_err_cont:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 			clear_opt (opts->s_mount_opt, ERRORS_RO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 			clear_opt (opts->s_mount_opt, ERRORS_PANIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 			set_opt (opts->s_mount_opt, ERRORS_CONT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 		case Opt_nouid32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 			set_opt (opts->s_mount_opt, NO_UID32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 		case Opt_debug:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 			set_opt (opts->s_mount_opt, DEBUG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 		case Opt_oldalloc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 			set_opt (opts->s_mount_opt, OLDALLOC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 		case Opt_orlov:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 			clear_opt (opts->s_mount_opt, OLDALLOC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 		case Opt_nobh:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 			set_opt (opts->s_mount_opt, NOBH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) #ifdef CONFIG_EXT2_FS_XATTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 		case Opt_user_xattr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 			set_opt (opts->s_mount_opt, XATTR_USER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 		case Opt_nouser_xattr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 			clear_opt (opts->s_mount_opt, XATTR_USER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 		case Opt_user_xattr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 		case Opt_nouser_xattr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 			ext2_msg(sb, KERN_INFO, "(no)user_xattr options"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 				"not supported");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) #ifdef CONFIG_EXT2_FS_POSIX_ACL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 		case Opt_acl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 			set_opt(opts->s_mount_opt, POSIX_ACL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 		case Opt_noacl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 			clear_opt(opts->s_mount_opt, POSIX_ACL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 		case Opt_acl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 		case Opt_noacl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 			ext2_msg(sb, KERN_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 				"(no)acl options not supported");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 		case Opt_xip:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 			ext2_msg(sb, KERN_INFO, "use dax instead of xip");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 			set_opt(opts->s_mount_opt, XIP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 			fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 		case Opt_dax:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) #ifdef CONFIG_FS_DAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 			ext2_msg(sb, KERN_WARNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 		"DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 			set_opt(opts->s_mount_opt, DAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 			ext2_msg(sb, KERN_INFO, "dax option not supported");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) #if defined(CONFIG_QUOTA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 		case Opt_quota:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 		case Opt_usrquota:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 			set_opt(opts->s_mount_opt, USRQUOTA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 		case Opt_grpquota:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 			set_opt(opts->s_mount_opt, GRPQUOTA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 		case Opt_quota:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 		case Opt_usrquota:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 		case Opt_grpquota:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 			ext2_msg(sb, KERN_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 				"quota operations not supported");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 		case Opt_reservation:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 			set_opt(opts->s_mount_opt, RESERVATION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 			ext2_msg(sb, KERN_INFO, "reservations ON");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 		case Opt_noreservation:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 			clear_opt(opts->s_mount_opt, RESERVATION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 			ext2_msg(sb, KERN_INFO, "reservations OFF");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 		case Opt_ignore:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) static int ext2_setup_super (struct super_block * sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 			      struct ext2_super_block * es,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 			      int read_only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 	int res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 	struct ext2_sb_info *sbi = EXT2_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 	if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 		ext2_msg(sb, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 			"error: revision level too high, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 			"forcing read-only mode");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 		res = SB_RDONLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 	if (read_only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 		return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 	if (!(sbi->s_mount_state & EXT2_VALID_FS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 		ext2_msg(sb, KERN_WARNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 			"warning: mounting unchecked fs, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 			"running e2fsck is recommended");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 	else if ((sbi->s_mount_state & EXT2_ERROR_FS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 		ext2_msg(sb, KERN_WARNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 			"warning: mounting fs with errors, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 			"running e2fsck is recommended");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 	else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 		 le16_to_cpu(es->s_mnt_count) >=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 		 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 		ext2_msg(sb, KERN_WARNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 			"warning: maximal mount count reached, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 			"running e2fsck is recommended");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 	else if (le32_to_cpu(es->s_checkinterval) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 		(le32_to_cpu(es->s_lastcheck) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 			le32_to_cpu(es->s_checkinterval) <=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 			ktime_get_real_seconds()))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 		ext2_msg(sb, KERN_WARNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 			"warning: checktime reached, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 			"running e2fsck is recommended");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 	if (!le16_to_cpu(es->s_max_mnt_count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 		es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 	le16_add_cpu(&es->s_mnt_count, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 	if (test_opt (sb, DEBUG))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 		ext2_msg(sb, KERN_INFO, "%s, %s, bs=%lu, fs=%lu, gc=%lu, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 			"bpg=%lu, ipg=%lu, mo=%04lx]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 			EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 			sbi->s_frag_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 			sbi->s_groups_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 			EXT2_BLOCKS_PER_GROUP(sb),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 			EXT2_INODES_PER_GROUP(sb),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 			sbi->s_mount_opt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 	return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) static int ext2_check_descriptors(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 	struct ext2_sb_info *sbi = EXT2_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 	ext2_debug ("Checking group descriptors");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 	for (i = 0; i < sbi->s_groups_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 		struct ext2_group_desc *gdp = ext2_get_group_desc(sb, i, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 		ext2_fsblk_t first_block = ext2_group_first_block_no(sb, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 		ext2_fsblk_t last_block = ext2_group_last_block_no(sb, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 		if (le32_to_cpu(gdp->bg_block_bitmap) < first_block ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 		    le32_to_cpu(gdp->bg_block_bitmap) > last_block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 			ext2_error (sb, "ext2_check_descriptors",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 				    "Block bitmap for group %d"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 				    " not in group (block %lu)!",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 				    i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 		if (le32_to_cpu(gdp->bg_inode_bitmap) < first_block ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 		    le32_to_cpu(gdp->bg_inode_bitmap) > last_block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 			ext2_error (sb, "ext2_check_descriptors",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 				    "Inode bitmap for group %d"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 				    " not in group (block %lu)!",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 				    i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 		if (le32_to_cpu(gdp->bg_inode_table) < first_block ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 		    le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group - 1 >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 		    last_block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 			ext2_error (sb, "ext2_check_descriptors",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 				    "Inode table for group %d"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 				    " not in group (block %lu)!",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 				    i, (unsigned long) le32_to_cpu(gdp->bg_inode_table));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732)  * Maximal file size.  There is a direct, and {,double-,triple-}indirect
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733)  * block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734)  * We need to be 1 filesystem block less than the 2^32 sector limit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) static loff_t ext2_max_size(int bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 	loff_t res = EXT2_NDIR_BLOCKS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 	int meta_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 	unsigned int upper_limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 	unsigned int ppb = 1 << (bits-2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 	/* This is calculated to be the largest file size for a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 	 * dense, file such that the total number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 	 * sectors in the file, including data and all indirect blocks,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 	 * does not exceed 2^32 -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 	 * __u32 i_blocks representing the total number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 	 * 512 bytes blocks of the file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 	upper_limit = (1LL << 32) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 	/* total blocks in file system block size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 	upper_limit >>= (bits - 9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 	/* Compute how many blocks we can address by block tree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 	res += 1LL << (bits-2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 	res += 1LL << (2*(bits-2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 	res += 1LL << (3*(bits-2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 	/* Compute how many metadata blocks are needed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 	meta_blocks = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 	meta_blocks += 1 + ppb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 	meta_blocks += 1 + ppb + ppb * ppb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 	/* Does block tree limit file size? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 	if (res + meta_blocks <= upper_limit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 		goto check_lfs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 	res = upper_limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	/* How many metadata blocks are needed for addressing upper_limit? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 	upper_limit -= EXT2_NDIR_BLOCKS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 	/* indirect blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 	meta_blocks = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 	upper_limit -= ppb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 	/* double indirect blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 	if (upper_limit < ppb * ppb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 		meta_blocks += 1 + DIV_ROUND_UP(upper_limit, ppb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 		res -= meta_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 		goto check_lfs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 	meta_blocks += 1 + ppb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	upper_limit -= ppb * ppb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 	/* tripple indirect blocks for the rest */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 	meta_blocks += 1 + DIV_ROUND_UP(upper_limit, ppb) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 		DIV_ROUND_UP(upper_limit, ppb*ppb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 	res -= meta_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) check_lfs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 	res <<= bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 	if (res > MAX_LFS_FILESIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 		res = MAX_LFS_FILESIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 	return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) static unsigned long descriptor_loc(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 				    unsigned long logic_sb_block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 				    int nr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 	struct ext2_sb_info *sbi = EXT2_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 	unsigned long bg, first_meta_bg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 	first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 	if (!EXT2_HAS_INCOMPAT_FEATURE(sb, EXT2_FEATURE_INCOMPAT_META_BG) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 	    nr < first_meta_bg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 		return (logic_sb_block + nr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 	bg = sbi->s_desc_per_block * nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 	return ext2_group_first_block_no(sb, bg) + ext2_bg_has_super(sb, bg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) static int ext2_fill_super(struct super_block *sb, void *data, int silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 	struct dax_device *dax_dev = fs_dax_get_by_bdev(sb->s_bdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 	struct buffer_head * bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 	struct ext2_sb_info * sbi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 	struct ext2_super_block * es;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 	struct inode *root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 	unsigned long block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 	unsigned long sb_block = get_sb_block(&data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 	unsigned long logic_sb_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 	unsigned long offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 	unsigned long def_mount_opts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 	long ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 	int blocksize = BLOCK_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 	int db_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 	int i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 	__le32 features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 	struct ext2_mount_options opts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 	sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 	if (!sbi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 		goto failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 	sbi->s_blockgroup_lock =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 		kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 	if (!sbi->s_blockgroup_lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 		kfree(sbi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 		goto failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 	sb->s_fs_info = sbi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 	sbi->s_sb_block = sb_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 	sbi->s_daxdev = dax_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 	spin_lock_init(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 	ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	 * See what the current blocksize for the device is, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 	 * use that as the blocksize.  Otherwise (or if the blocksize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 	 * is smaller than the default) use the default.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 	 * This is important for devices that have a hardware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 	 * sectorsize that is larger than the default.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 	blocksize = sb_min_blocksize(sb, BLOCK_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 	if (!blocksize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 		ext2_msg(sb, KERN_ERR, "error: unable to set blocksize");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 		goto failed_sbi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 	 * If the superblock doesn't start on a hardware sector boundary,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 	 * calculate the offset.  
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 	if (blocksize != BLOCK_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 		logic_sb_block = (sb_block*BLOCK_SIZE) / blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 		offset = (sb_block*BLOCK_SIZE) % blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 		logic_sb_block = sb_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 	if (!(bh = sb_bread(sb, logic_sb_block))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 		ext2_msg(sb, KERN_ERR, "error: unable to read superblock");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 		goto failed_sbi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 	 * Note: s_es must be initialized as soon as possible because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 	 *       some ext2 macro-instructions depend on its value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 	es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 	sbi->s_es = es;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 	sb->s_magic = le16_to_cpu(es->s_magic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 	if (sb->s_magic != EXT2_SUPER_MAGIC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 		goto cantfind_ext2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 	opts.s_mount_opt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 	/* Set defaults before we parse the mount options */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 	def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 	if (def_mount_opts & EXT2_DEFM_DEBUG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 		set_opt(opts.s_mount_opt, DEBUG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 	if (def_mount_opts & EXT2_DEFM_BSDGROUPS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 		set_opt(opts.s_mount_opt, GRPID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 	if (def_mount_opts & EXT2_DEFM_UID16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 		set_opt(opts.s_mount_opt, NO_UID32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) #ifdef CONFIG_EXT2_FS_XATTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 	if (def_mount_opts & EXT2_DEFM_XATTR_USER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 		set_opt(opts.s_mount_opt, XATTR_USER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) #ifdef CONFIG_EXT2_FS_POSIX_ACL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 	if (def_mount_opts & EXT2_DEFM_ACL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 		set_opt(opts.s_mount_opt, POSIX_ACL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 	if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_PANIC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 		set_opt(opts.s_mount_opt, ERRORS_PANIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 	else if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_CONTINUE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 		set_opt(opts.s_mount_opt, ERRORS_CONT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 		set_opt(opts.s_mount_opt, ERRORS_RO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 	opts.s_resuid = make_kuid(&init_user_ns, le16_to_cpu(es->s_def_resuid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 	opts.s_resgid = make_kgid(&init_user_ns, le16_to_cpu(es->s_def_resgid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 	set_opt(opts.s_mount_opt, RESERVATION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 	if (!parse_options((char *) data, sb, &opts))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 		goto failed_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 	sbi->s_mount_opt = opts.s_mount_opt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 	sbi->s_resuid = opts.s_resuid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 	sbi->s_resgid = opts.s_resgid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 	sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 		(test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 	sb->s_iflags |= SB_I_CGROUPWB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 	if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 	    (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 	     EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 	     EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 		ext2_msg(sb, KERN_WARNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 			"warning: feature flags set on rev 0 fs, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 			"running e2fsck is recommended");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 	 * Check feature flags regardless of the revision level, since we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 	 * previously didn't change the revision level when setting the flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 	 * so there is a chance incompat flags are set on a rev 0 filesystem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 	features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 	if (features) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 		ext2_msg(sb, KERN_ERR,	"error: couldn't mount because of "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 		       "unsupported optional features (%x)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 			le32_to_cpu(features));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 		goto failed_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 	if (!sb_rdonly(sb) && (features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 		ext2_msg(sb, KERN_ERR, "error: couldn't mount RDWR because of "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 		       "unsupported optional features (%x)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 		       le32_to_cpu(features));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 		goto failed_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 	blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 	if (test_opt(sb, DAX)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 		if (!bdev_dax_supported(sb->s_bdev, blocksize)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 			ext2_msg(sb, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 				"DAX unsupported by block device. Turning off DAX.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 			clear_opt(sbi->s_mount_opt, DAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 	/* If the blocksize doesn't match, re-read the thing.. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 	if (sb->s_blocksize != blocksize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 		brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 		if (!sb_set_blocksize(sb, blocksize)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 			ext2_msg(sb, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 				"error: bad blocksize %d", blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 			goto failed_sbi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 		logic_sb_block = (sb_block*BLOCK_SIZE) / blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 		offset = (sb_block*BLOCK_SIZE) % blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 		bh = sb_bread(sb, logic_sb_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 		if(!bh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 			ext2_msg(sb, KERN_ERR, "error: couldn't read"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 				"superblock on 2nd try");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 			goto failed_sbi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 		es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 		sbi->s_es = es;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 		if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 			ext2_msg(sb, KERN_ERR, "error: magic mismatch");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 			goto failed_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 	sb->s_maxbytes = ext2_max_size(sb->s_blocksize_bits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 	sb->s_max_links = EXT2_LINK_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 	sb->s_time_min = S32_MIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 	sb->s_time_max = S32_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 	if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 		sbi->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 		sbi->s_first_ino = EXT2_GOOD_OLD_FIRST_INO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 		sbi->s_inode_size = le16_to_cpu(es->s_inode_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 		sbi->s_first_ino = le32_to_cpu(es->s_first_ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 		if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 		    !is_power_of_2(sbi->s_inode_size) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 		    (sbi->s_inode_size > blocksize)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 			ext2_msg(sb, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 				"error: unsupported inode size: %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 				sbi->s_inode_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 			goto failed_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 	sbi->s_frag_size = EXT2_MIN_FRAG_SIZE <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 				   le32_to_cpu(es->s_log_frag_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	if (sbi->s_frag_size == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 		goto cantfind_ext2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 	sbi->s_frags_per_block = sb->s_blocksize / sbi->s_frag_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 	sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 	sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 	sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 	sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 	if (sbi->s_inodes_per_block == 0 || sbi->s_inodes_per_group == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 		goto cantfind_ext2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 	sbi->s_itb_per_group = sbi->s_inodes_per_group /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 					sbi->s_inodes_per_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 	sbi->s_desc_per_block = sb->s_blocksize /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 					sizeof (struct ext2_group_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 	sbi->s_sbh = bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 	sbi->s_mount_state = le16_to_cpu(es->s_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 	sbi->s_addr_per_block_bits =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 		ilog2 (EXT2_ADDR_PER_BLOCK(sb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 	sbi->s_desc_per_block_bits =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 		ilog2 (EXT2_DESC_PER_BLOCK(sb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	if (sb->s_magic != EXT2_SUPER_MAGIC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 		goto cantfind_ext2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 	if (sb->s_blocksize != bh->b_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 		if (!silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 			ext2_msg(sb, KERN_ERR, "error: unsupported blocksize");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 		goto failed_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 	if (sb->s_blocksize != sbi->s_frag_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 		ext2_msg(sb, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 			"error: fragsize %lu != blocksize %lu"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 			"(not supported yet)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 			sbi->s_frag_size, sb->s_blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 		goto failed_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 	if (sbi->s_blocks_per_group > sb->s_blocksize * 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 		ext2_msg(sb, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 			"error: #blocks per group too big: %lu",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 			sbi->s_blocks_per_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 		goto failed_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 	if (sbi->s_frags_per_group > sb->s_blocksize * 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 		ext2_msg(sb, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 			"error: #fragments per group too big: %lu",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 			sbi->s_frags_per_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 		goto failed_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 	if (sbi->s_inodes_per_group > sb->s_blocksize * 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 		ext2_msg(sb, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 			"error: #inodes per group too big: %lu",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 			sbi->s_inodes_per_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 		goto failed_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 	if (EXT2_BLOCKS_PER_GROUP(sb) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 		goto cantfind_ext2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 	sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 				le32_to_cpu(es->s_first_data_block) - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 					/ EXT2_BLOCKS_PER_GROUP(sb)) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 	db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 		   EXT2_DESC_PER_BLOCK(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 	sbi->s_group_desc = kmalloc_array (db_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 					   sizeof(struct buffer_head *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 					   GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 	if (sbi->s_group_desc == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 		ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 		ext2_msg(sb, KERN_ERR, "error: not enough memory");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 		goto failed_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 	bgl_lock_init(sbi->s_blockgroup_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) 	sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 	if (!sbi->s_debts) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) 		ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 		ext2_msg(sb, KERN_ERR, "error: not enough memory");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 		goto failed_mount_group_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 	for (i = 0; i < db_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 		block = descriptor_loc(sb, logic_sb_block, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) 		sbi->s_group_desc[i] = sb_bread(sb, block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 		if (!sbi->s_group_desc[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 			for (j = 0; j < i; j++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 				brelse (sbi->s_group_desc[j]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 			ext2_msg(sb, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 				"error: unable to read group descriptors");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 			goto failed_mount_group_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 	if (!ext2_check_descriptors (sb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 		ext2_msg(sb, KERN_ERR, "group descriptors corrupted");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 		goto failed_mount2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 	sbi->s_gdb_count = db_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 	get_random_bytes(&sbi->s_next_generation, sizeof(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 	spin_lock_init(&sbi->s_next_gen_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 	/* per fileystem reservation list head & lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 	spin_lock_init(&sbi->s_rsv_window_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 	sbi->s_rsv_window_root = RB_ROOT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 	 * Add a single, static dummy reservation to the start of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 	 * reservation window list --- it gives us a placeholder for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 	 * append-at-start-of-list which makes the allocation logic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 	 * _much_ simpler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 	sbi->s_rsv_window_head.rsv_start = EXT2_RESERVE_WINDOW_NOT_ALLOCATED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 	sbi->s_rsv_window_head.rsv_end = EXT2_RESERVE_WINDOW_NOT_ALLOCATED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) 	sbi->s_rsv_window_head.rsv_alloc_hit = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 	sbi->s_rsv_window_head.rsv_goal_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 	ext2_rsv_window_add(sb, &sbi->s_rsv_window_head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 	err = percpu_counter_init(&sbi->s_freeblocks_counter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 				ext2_count_free_blocks(sb), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 	if (!err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 		err = percpu_counter_init(&sbi->s_freeinodes_counter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 				ext2_count_free_inodes(sb), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) 	if (!err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 		err = percpu_counter_init(&sbi->s_dirs_counter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) 				ext2_count_dirs(sb), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 	if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 		ret = err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 		ext2_msg(sb, KERN_ERR, "error: insufficient memory");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 		goto failed_mount3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) #ifdef CONFIG_EXT2_FS_XATTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 	sbi->s_ea_block_cache = ext2_xattr_create_cache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) 	if (!sbi->s_ea_block_cache) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 		ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) 		ext2_msg(sb, KERN_ERR, "Failed to create ea_block_cache");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 		goto failed_mount3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 	 * set up enough so that it can read an inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 	sb->s_op = &ext2_sops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 	sb->s_export_op = &ext2_export_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 	sb->s_xattr = ext2_xattr_handlers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) #ifdef CONFIG_QUOTA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 	sb->dq_op = &dquot_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 	sb->s_qcop = &ext2_quotactl_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 	root = ext2_iget(sb, EXT2_ROOT_INO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 	if (IS_ERR(root)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 		ret = PTR_ERR(root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) 		goto failed_mount3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 	if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 		iput(root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 		ext2_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 		goto failed_mount3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 	sb->s_root = d_make_root(root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 	if (!sb->s_root) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 		ext2_msg(sb, KERN_ERR, "error: get root inode failed");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 		ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) 		goto failed_mount3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) 	if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 		ext2_msg(sb, KERN_WARNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) 			"warning: mounting ext3 filesystem as ext2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 	if (ext2_setup_super (sb, es, sb_rdonly(sb)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) 		sb->s_flags |= SB_RDONLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) 	ext2_write_super(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) cantfind_ext2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) 	if (!silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 		ext2_msg(sb, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 			"error: can't find an ext2 filesystem on dev %s.",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) 			sb->s_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 	goto failed_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) failed_mount3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) 	ext2_xattr_destroy_cache(sbi->s_ea_block_cache);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 	percpu_counter_destroy(&sbi->s_freeblocks_counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 	percpu_counter_destroy(&sbi->s_freeinodes_counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 	percpu_counter_destroy(&sbi->s_dirs_counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) failed_mount2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 	for (i = 0; i < db_count; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 		brelse(sbi->s_group_desc[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) failed_mount_group_desc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) 	kfree(sbi->s_group_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) 	kfree(sbi->s_debts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) failed_mount:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 	brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) failed_sbi:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) 	sb->s_fs_info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) 	kfree(sbi->s_blockgroup_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 	kfree(sbi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) failed:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 	fs_put_dax(dax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) static void ext2_clear_super_error(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) 	struct buffer_head *sbh = EXT2_SB(sb)->s_sbh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 	if (buffer_write_io_error(sbh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 		 * Oh, dear.  A previous attempt to write the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) 		 * superblock failed.  This could happen because the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 		 * USB device was yanked out.  Or it could happen to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 		 * be a transient write error and maybe the block will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 		 * be remapped.  Nothing we can do but to retry the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) 		 * write and hope for the best.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) 		ext2_msg(sb, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 		       "previous I/O error to superblock detected");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 		clear_buffer_write_io_error(sbh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 		set_buffer_uptodate(sbh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) 		     int wait)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) 	ext2_clear_super_error(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) 	spin_lock(&EXT2_SB(sb)->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) 	es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) 	es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) 	es->s_wtime = cpu_to_le32(ktime_get_real_seconds());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) 	/* unlock before we do IO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) 	spin_unlock(&EXT2_SB(sb)->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 	mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) 	if (wait)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 		sync_dirty_buffer(EXT2_SB(sb)->s_sbh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252)  * In the second extended file system, it is not necessary to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253)  * write the super block since we use a mapping of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254)  * disk super block in a buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256)  * However, this function is still used to set the fs valid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257)  * flags to 0.  We need to set this flag to 0 since the fs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258)  * may have been checked while mounted and e2fsck may have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259)  * set s_state to EXT2_VALID_FS after some corrections.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) static int ext2_sync_fs(struct super_block *sb, int wait)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 	struct ext2_sb_info *sbi = EXT2_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) 	struct ext2_super_block *es = EXT2_SB(sb)->s_es;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) 	 * Write quota structures to quota file, sync_blockdev() will write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) 	 * them to disk later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) 	dquot_writeback_dquots(sb, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) 	spin_lock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) 	if (es->s_state & cpu_to_le16(EXT2_VALID_FS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) 		ext2_debug("setting valid to 0\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) 		es->s_state &= cpu_to_le16(~EXT2_VALID_FS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) 	spin_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) 	ext2_sync_super(sb, es, wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) static int ext2_freeze(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) 	struct ext2_sb_info *sbi = EXT2_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) 	 * Open but unlinked files present? Keep EXT2_VALID_FS flag cleared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) 	 * because we have unattached inodes and thus filesystem is not fully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) 	 * consistent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) 	if (atomic_long_read(&sb->s_remove_count)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) 		ext2_sync_fs(sb, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) 	/* Set EXT2_FS_VALID flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) 	spin_lock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) 	sbi->s_es->s_state = cpu_to_le16(sbi->s_mount_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) 	spin_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) 	ext2_sync_super(sb, sbi->s_es, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) static int ext2_unfreeze(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) 	/* Just write sb to clear EXT2_VALID_FS flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) 	ext2_write_super(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) static void ext2_write_super(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) 	if (!sb_rdonly(sb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) 		ext2_sync_fs(sb, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) static int ext2_remount (struct super_block * sb, int * flags, char * data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) 	struct ext2_sb_info * sbi = EXT2_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) 	struct ext2_super_block * es;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) 	struct ext2_mount_options new_opts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) 	sync_filesystem(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 	spin_lock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) 	new_opts.s_mount_opt = sbi->s_mount_opt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) 	new_opts.s_resuid = sbi->s_resuid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) 	new_opts.s_resgid = sbi->s_resgid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) 	spin_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) 	if (!parse_options(data, sb, &new_opts))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) 	spin_lock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) 	es = sbi->s_es;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) 	if ((sbi->s_mount_opt ^ new_opts.s_mount_opt) & EXT2_MOUNT_DAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) 		ext2_msg(sb, KERN_WARNING, "warning: refusing change of "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) 			 "dax flag with busy inodes while remounting");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) 		new_opts.s_mount_opt ^= EXT2_MOUNT_DAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) 	if ((bool)(*flags & SB_RDONLY) == sb_rdonly(sb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) 		goto out_set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) 	if (*flags & SB_RDONLY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) 		if (le16_to_cpu(es->s_state) & EXT2_VALID_FS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) 		    !(sbi->s_mount_state & EXT2_VALID_FS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) 			goto out_set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) 		 * OK, we are remounting a valid rw partition rdonly, so set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) 		 * the rdonly flag and then mark the partition as valid again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) 		es->s_state = cpu_to_le16(sbi->s_mount_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) 		es->s_mtime = cpu_to_le32(ktime_get_real_seconds());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) 		spin_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) 		err = dquot_suspend(sb, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) 		if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) 		ext2_sync_super(sb, es, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) 		__le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) 					       ~EXT2_FEATURE_RO_COMPAT_SUPP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) 		if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) 			spin_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) 			ext2_msg(sb, KERN_WARNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) 				"warning: couldn't remount RDWR because of "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) 				"unsupported optional features (%x).",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) 				le32_to_cpu(ret));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) 			return -EROFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) 		 * Mounting a RDONLY partition read-write, so reread and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) 		 * store the current valid flag.  (It may have been changed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) 		 * by e2fsck since we originally mounted the partition.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) 		sbi->s_mount_state = le16_to_cpu(es->s_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) 		if (!ext2_setup_super (sb, es, 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) 			sb->s_flags &= ~SB_RDONLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) 		spin_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) 		ext2_write_super(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) 		dquot_resume(sb, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) 	spin_lock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) out_set:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) 	sbi->s_mount_opt = new_opts.s_mount_opt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) 	sbi->s_resuid = new_opts.s_resuid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) 	sbi->s_resgid = new_opts.s_resgid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) 	sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) 		(test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) 	spin_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) 	struct super_block *sb = dentry->d_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) 	struct ext2_sb_info *sbi = EXT2_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) 	struct ext2_super_block *es = sbi->s_es;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) 	u64 fsid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) 	spin_lock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) 	if (test_opt (sb, MINIX_DF))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) 		sbi->s_overhead_last = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) 	else if (sbi->s_blocks_last != le32_to_cpu(es->s_blocks_count)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) 		unsigned long i, overhead = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) 		smp_rmb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) 		 * Compute the overhead (FS structures). This is constant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) 		 * for a given filesystem unless the number of block groups
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) 		 * changes so we cache the previous value until it does.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) 		 * All of the blocks before first_data_block are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) 		 * overhead
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) 		overhead = le32_to_cpu(es->s_first_data_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) 		 * Add the overhead attributed to the superblock and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) 		 * block group descriptors.  If the sparse superblocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) 		 * feature is turned on, then not all groups have this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) 		for (i = 0; i < sbi->s_groups_count; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) 			overhead += ext2_bg_has_super(sb, i) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) 				ext2_bg_num_gdb(sb, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) 		 * Every block group has an inode bitmap, a block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) 		 * bitmap, and an inode table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) 		overhead += (sbi->s_groups_count *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) 			     (2 + sbi->s_itb_per_group));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) 		sbi->s_overhead_last = overhead;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) 		smp_wmb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) 		sbi->s_blocks_last = le32_to_cpu(es->s_blocks_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) 	buf->f_type = EXT2_SUPER_MAGIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) 	buf->f_bsize = sb->s_blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) 	buf->f_blocks = le32_to_cpu(es->s_blocks_count) - sbi->s_overhead_last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) 	buf->f_bfree = ext2_count_free_blocks(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) 	es->s_free_blocks_count = cpu_to_le32(buf->f_bfree);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) 	buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) 	if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) 		buf->f_bavail = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) 	buf->f_files = le32_to_cpu(es->s_inodes_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) 	buf->f_ffree = ext2_count_free_inodes(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) 	es->s_free_inodes_count = cpu_to_le32(buf->f_ffree);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) 	buf->f_namelen = EXT2_NAME_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) 	fsid = le64_to_cpup((void *)es->s_uuid) ^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) 	       le64_to_cpup((void *)es->s_uuid + sizeof(u64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) 	buf->f_fsid = u64_to_fsid(fsid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) 	spin_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) static struct dentry *ext2_mount(struct file_system_type *fs_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) 	int flags, const char *dev_name, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) 	return mount_bdev(fs_type, flags, dev_name, data, ext2_fill_super);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) #ifdef CONFIG_QUOTA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) /* Read data from quotafile - avoid pagecache and such because we cannot afford
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476)  * acquiring the locks... As quota files are never truncated and quota code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477)  * itself serializes the operations (and no one else should touch the files)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478)  * we don't have to be afraid of races */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) 			       size_t len, loff_t off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) 	struct inode *inode = sb_dqopt(sb)->files[type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) 	sector_t blk = off >> EXT2_BLOCK_SIZE_BITS(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) 	int offset = off & (sb->s_blocksize - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) 	int tocopy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) 	size_t toread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) 	struct buffer_head tmp_bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) 	struct buffer_head *bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) 	loff_t i_size = i_size_read(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) 	if (off > i_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) 	if (off+len > i_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) 		len = i_size-off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) 	toread = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) 	while (toread > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) 		tocopy = sb->s_blocksize - offset < toread ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) 				sb->s_blocksize - offset : toread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) 		tmp_bh.b_state = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) 		tmp_bh.b_size = sb->s_blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) 		err = ext2_get_block(inode, blk, &tmp_bh, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) 		if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) 		if (!buffer_mapped(&tmp_bh))	/* A hole? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) 			memset(data, 0, tocopy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) 		else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) 			bh = sb_bread(sb, tmp_bh.b_blocknr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) 			if (!bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) 				return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) 			memcpy(data, bh->b_data+offset, tocopy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) 			brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) 		offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) 		toread -= tocopy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) 		data += tocopy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) 		blk++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) /* Write to quotafile */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) static ssize_t ext2_quota_write(struct super_block *sb, int type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) 				const char *data, size_t len, loff_t off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) 	struct inode *inode = sb_dqopt(sb)->files[type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) 	sector_t blk = off >> EXT2_BLOCK_SIZE_BITS(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) 	int offset = off & (sb->s_blocksize - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) 	int tocopy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) 	size_t towrite = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) 	struct buffer_head tmp_bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) 	struct buffer_head *bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) 	while (towrite > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) 		tocopy = sb->s_blocksize - offset < towrite ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) 				sb->s_blocksize - offset : towrite;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) 		tmp_bh.b_state = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) 		tmp_bh.b_size = sb->s_blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) 		err = ext2_get_block(inode, blk, &tmp_bh, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) 		if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) 		if (offset || tocopy != EXT2_BLOCK_SIZE(sb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) 			bh = sb_bread(sb, tmp_bh.b_blocknr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) 			bh = sb_getblk(sb, tmp_bh.b_blocknr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) 		if (unlikely(!bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) 			err = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) 		lock_buffer(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) 		memcpy(bh->b_data+offset, data, tocopy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) 		flush_dcache_page(bh->b_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) 		set_buffer_uptodate(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) 		mark_buffer_dirty(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) 		unlock_buffer(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) 		brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) 		offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) 		towrite -= tocopy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) 		data += tocopy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) 		blk++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) 	if (len == towrite)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) 	if (inode->i_size < off+len-towrite)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) 		i_size_write(inode, off+len-towrite);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) 	inode_inc_iversion(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) 	inode->i_mtime = inode->i_ctime = current_time(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) 	mark_inode_dirty(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) 	return len - towrite;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) static int ext2_quota_on(struct super_block *sb, int type, int format_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) 			 const struct path *path)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) 	struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) 	err = dquot_quota_on(sb, type, format_id, path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) 	inode = d_inode(path->dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) 	inode_lock(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) 	EXT2_I(inode)->i_flags |= EXT2_NOATIME_FL | EXT2_IMMUTABLE_FL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) 	inode_set_flags(inode, S_NOATIME | S_IMMUTABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) 			S_NOATIME | S_IMMUTABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) 	inode_unlock(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) 	mark_inode_dirty(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) static int ext2_quota_off(struct super_block *sb, int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) 	struct inode *inode = sb_dqopt(sb)->files[type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) 	if (!inode || !igrab(inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) 	err = dquot_quota_off(sb, type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) 		goto out_put;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) 	inode_lock(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) 	EXT2_I(inode)->i_flags &= ~(EXT2_NOATIME_FL | EXT2_IMMUTABLE_FL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) 	inode_set_flags(inode, 0, S_NOATIME | S_IMMUTABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) 	inode_unlock(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) 	mark_inode_dirty(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) out_put:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) 	iput(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) 	return dquot_quota_off(sb, type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) static struct file_system_type ext2_fs_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) 	.owner		= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) 	.name		= "ext2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) 	.mount		= ext2_mount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) 	.kill_sb	= kill_block_super,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) 	.fs_flags	= FS_REQUIRES_DEV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) MODULE_ALIAS_FS("ext2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) static int __init init_ext2_fs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) 	err = init_inodecache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639)         err = register_filesystem(&ext2_fs_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) 	destroy_inodecache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) static void __exit exit_ext2_fs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) 	unregister_filesystem(&ext2_fs_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) 	destroy_inodecache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) MODULE_AUTHOR("Remy Card and others");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) MODULE_DESCRIPTION("Second Extended Filesystem");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) module_init(init_ext2_fs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) module_exit(exit_ext2_fs)