2019-05-19 20:08:20 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* linux/fs/ext2/super.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992, 1993, 1994, 1995
|
|
|
|
* Remy Card (card@masi.ibp.fr)
|
|
|
|
* Laboratoire MASI - Institut Blaise Pascal
|
|
|
|
* Universite Pierre et Marie Curie (Paris VI)
|
|
|
|
*
|
|
|
|
* from
|
|
|
|
*
|
|
|
|
* linux/fs/minix/inode.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 1991, 1992 Linus Torvalds
|
|
|
|
*
|
|
|
|
* Big-endian to little-endian byte-swapping/bitmaps by
|
|
|
|
* David S. Miller (davem@caip.rutgers.edu), 1995
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/string.h>
|
2005-09-07 06:16:54 +08:00
|
|
|
#include <linux/fs.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/parser.h>
|
|
|
|
#include <linux/random.h>
|
|
|
|
#include <linux/buffer_head.h>
|
2007-07-17 19:04:28 +08:00
|
|
|
#include <linux/exportfs.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/vfs.h>
|
2005-09-07 06:16:54 +08:00
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <linux/mount.h>
|
2007-10-17 14:27:14 +08:00
|
|
|
#include <linux/log2.h>
|
2008-07-25 16:46:51 +08:00
|
|
|
#include <linux/quotaops.h>
|
2016-12-25 03:46:01 +08:00
|
|
|
#include <linux/uaccess.h>
|
2017-05-09 01:55:27 +08:00
|
|
|
#include <linux/dax.h>
|
2017-12-11 19:35:14 +08:00
|
|
|
#include <linux/iversion.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include "ext2.h"
|
|
|
|
#include "xattr.h"
|
|
|
|
#include "acl.h"
|
|
|
|
|
2017-04-05 19:32:52 +08:00
|
|
|
static void ext2_write_super(struct super_block *sb);
|
2005-04-17 06:20:36 +08:00
|
|
|
static int ext2_remount (struct super_block * sb, int * flags, char * data);
|
2006-06-23 17:02:58 +08:00
|
|
|
static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf);
|
2009-06-08 16:04:17 +08:00
|
|
|
static int ext2_sync_fs(struct super_block *sb, int wait);
|
2012-06-12 22:20:46 +08:00
|
|
|
static int ext2_freeze(struct super_block *sb);
|
|
|
|
static int ext2_unfreeze(struct super_block *sb);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-11-10 02:16:03 +08:00
|
|
|
void ext2_error(struct super_block *sb, const char *function,
|
|
|
|
const char *fmt, ...)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-11-10 02:16:03 +08:00
|
|
|
struct va_format vaf;
|
2005-04-17 06:20:36 +08:00
|
|
|
va_list args;
|
|
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
|
|
|
struct ext2_super_block *es = sbi->s_es;
|
|
|
|
|
2017-07-17 15:45:34 +08:00
|
|
|
if (!sb_rdonly(sb)) {
|
2010-04-14 20:38:38 +08:00
|
|
|
spin_lock(&sbi->s_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
sbi->s_mount_state |= EXT2_ERROR_FS;
|
2008-04-28 17:16:00 +08:00
|
|
|
es->s_state |= cpu_to_le16(EXT2_ERROR_FS);
|
2010-04-14 20:38:38 +08:00
|
|
|
spin_unlock(&sbi->s_lock);
|
2010-04-14 20:38:36 +08:00
|
|
|
ext2_sync_super(sb, es, 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
2010-11-10 02:16:03 +08:00
|
|
|
|
|
|
|
vaf.fmt = fmt;
|
|
|
|
vaf.va = &args;
|
|
|
|
|
|
|
|
printk(KERN_CRIT "EXT2-fs (%s): error: %s: %pV\n",
|
|
|
|
sb->s_id, function, &vaf);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
if (test_opt(sb, ERRORS_PANIC))
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
panic("EXT2-fs: panic from previous error\n");
|
2018-11-07 21:47:04 +08:00
|
|
|
if (!sb_rdonly(sb) && test_opt(sb, ERRORS_RO)) {
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_CRIT,
|
|
|
|
"error: remounting filesystem read-only");
|
2017-11-28 05:05:09 +08:00
|
|
|
sb->s_flags |= SB_RDONLY;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
void ext2_msg(struct super_block *sb, const char *prefix,
|
|
|
|
const char *fmt, ...)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-11-10 02:16:03 +08:00
|
|
|
struct va_format vaf;
|
2005-04-17 06:20:36 +08:00
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
2010-11-10 02:16:03 +08:00
|
|
|
|
|
|
|
vaf.fmt = fmt;
|
|
|
|
vaf.va = &args;
|
|
|
|
|
|
|
|
printk("%sEXT2-fs (%s): %pV\n", prefix, sb->s_id, &vaf);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
2010-04-14 20:38:38 +08:00
|
|
|
/*
|
|
|
|
* This must be called with sbi->s_lock held.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
void ext2_update_dynamic_rev(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct ext2_super_block *es = EXT2_SB(sb)->s_es;
|
|
|
|
|
|
|
|
if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV)
|
|
|
|
return;
|
|
|
|
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_WARNING,
|
|
|
|
"warning: updating to rev %d because of "
|
|
|
|
"new feature flag, running e2fsck is recommended",
|
2005-04-17 06:20:36 +08:00
|
|
|
EXT2_DYNAMIC_REV);
|
|
|
|
|
|
|
|
es->s_first_ino = cpu_to_le32(EXT2_GOOD_OLD_FIRST_INO);
|
|
|
|
es->s_inode_size = cpu_to_le16(EXT2_GOOD_OLD_INODE_SIZE);
|
|
|
|
es->s_rev_level = cpu_to_le32(EXT2_DYNAMIC_REV);
|
|
|
|
/* leave es->s_feature_*compat flags alone */
|
|
|
|
/* es->s_uuid will be set by e2fsck if empty */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The rest of the superblock fields should be zero, and if not it
|
|
|
|
* means they are likely already in use, so leave them alone. We
|
|
|
|
* can leave it up to e2fsck to clean up any inconsistencies there.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2017-04-06 23:02:09 +08:00
|
|
|
#ifdef CONFIG_QUOTA
|
|
|
|
static int ext2_quota_off(struct super_block *sb, int type);
|
|
|
|
|
|
|
|
static void ext2_quota_off_umount(struct super_block *sb)
|
|
|
|
{
|
|
|
|
int type;
|
|
|
|
|
|
|
|
for (type = 0; type < MAXQUOTAS; type++)
|
|
|
|
ext2_quota_off(sb, type);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static inline void ext2_quota_off_umount(struct super_block *sb)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static void ext2_put_super (struct super_block * sb)
|
|
|
|
{
|
|
|
|
int db_count;
|
|
|
|
int i;
|
|
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
|
|
|
|
2017-04-06 23:02:09 +08:00
|
|
|
ext2_quota_off_umount(sb);
|
2010-05-19 19:16:42 +08:00
|
|
|
|
2018-11-14 07:23:53 +08:00
|
|
|
ext2_xattr_destroy_cache(sbi->s_ea_block_cache);
|
|
|
|
sbi->s_ea_block_cache = NULL;
|
|
|
|
|
2017-07-17 15:45:34 +08:00
|
|
|
if (!sb_rdonly(sb)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
struct ext2_super_block *es = sbi->s_es;
|
|
|
|
|
2010-04-14 20:38:38 +08:00
|
|
|
spin_lock(&sbi->s_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
es->s_state = cpu_to_le16(sbi->s_mount_state);
|
2010-04-14 20:38:38 +08:00
|
|
|
spin_unlock(&sbi->s_lock);
|
2010-04-14 20:38:36 +08:00
|
|
|
ext2_sync_super(sb, es, 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
db_count = sbi->s_gdb_count;
|
|
|
|
for (i = 0; i < db_count; i++)
|
2019-09-03 20:40:18 +08:00
|
|
|
brelse(sbi->s_group_desc[i]);
|
2005-04-17 06:20:36 +08:00
|
|
|
kfree(sbi->s_group_desc);
|
|
|
|
kfree(sbi->s_debts);
|
|
|
|
percpu_counter_destroy(&sbi->s_freeblocks_counter);
|
|
|
|
percpu_counter_destroy(&sbi->s_freeinodes_counter);
|
|
|
|
percpu_counter_destroy(&sbi->s_dirs_counter);
|
|
|
|
brelse (sbi->s_sbh);
|
|
|
|
sb->s_fs_info = NULL;
|
2009-01-08 10:07:19 +08:00
|
|
|
kfree(sbi->s_blockgroup_lock);
|
dax: introduce holder for dax_device
Patch series "v14 fsdax-rmap + v11 fsdax-reflink", v2.
The patchset fsdax-rmap is aimed to support shared pages tracking for
fsdax.
It moves owner tracking from dax_assocaite_entry() to pmem device driver,
by introducing an interface ->memory_failure() for struct pagemap. This
interface is called by memory_failure() in mm, and implemented by pmem
device.
Then call holder operations to find the filesystem which the corrupted
data located in, and call filesystem handler to track files or metadata
associated with this page.
Finally we are able to try to fix the corrupted data in filesystem and do
other necessary processing, such as killing processes who are using the
files affected.
The call trace is like this:
memory_failure()
|* fsdax case
|------------
|pgmap->ops->memory_failure() => pmem_pgmap_memory_failure()
| dax_holder_notify_failure() =>
| dax_device->holder_ops->notify_failure() =>
| - xfs_dax_notify_failure()
| |* xfs_dax_notify_failure()
| |--------------------------
| | xfs_rmap_query_range()
| | xfs_dax_failure_fn()
| | * corrupted on metadata
| | try to recover data, call xfs_force_shutdown()
| | * corrupted on file data
| | try to recover data, call mf_dax_kill_procs()
|* normal case
|-------------
|mf_generic_kill_procs()
The patchset fsdax-reflink attempts to add CoW support for fsdax, and
takes XFS, which has both reflink and fsdax features, as an example.
One of the key mechanisms needed to be implemented in fsdax is CoW. Copy
the data from srcmap before we actually write data to the destination
iomap. And we just copy range in which data won't be changed.
Another mechanism is range comparison. In page cache case, readpage() is
used to load data on disk to page cache in order to be able to compare
data. In fsdax case, readpage() does not work. So, we need another
compare data with direct access support.
With the two mechanisms implemented in fsdax, we are able to make reflink
and fsdax work together in XFS.
This patch (of 14):
To easily track filesystem from a pmem device, we introduce a holder for
dax_device structure, and also its operation. This holder is used to
remember who is using this dax_device:
- When it is the backend of a filesystem, the holder will be the
instance of this filesystem.
- When this pmem device is one of the targets in a mapped device, the
holder will be this mapped device. In this case, the mapped device
has its own dax_device and it will follow the first rule. So that we
can finally track to the filesystem we needed.
The holder and holder_ops will be set when filesystem is being mounted,
or an target device is being activated.
Link: https://lkml.kernel.org/r/20220603053738.1218681-1-ruansy.fnst@fujitsu.com
Link: https://lkml.kernel.org/r/20220603053738.1218681-2-ruansy.fnst@fujitsu.com
Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dan Williams <dan.j.wiliams@intel.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Jane Chu <jane.chu@oracle.com>
Cc: Goldwyn Rodrigues <rgoldwyn@suse.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Goldwyn Rodrigues <rgoldwyn@suse.com>
Cc: Ritesh Harjani <riteshh@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2022-06-03 13:37:25 +08:00
|
|
|
fs_put_dax(sbi->s_daxdev, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
kfree(sbi);
|
|
|
|
}
|
|
|
|
|
2006-12-07 12:33:20 +08:00
|
|
|
static struct kmem_cache * ext2_inode_cachep;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static struct inode *ext2_alloc_inode(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct ext2_inode_info *ei;
|
2022-03-23 05:41:03 +08:00
|
|
|
ei = alloc_inode_sb(sb, ext2_inode_cachep, GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!ei)
|
|
|
|
return NULL;
|
2007-10-17 14:30:46 +08:00
|
|
|
ei->i_block_alloc_info = NULL;
|
2017-12-11 19:35:14 +08:00
|
|
|
inode_set_iversion(&ei->vfs_inode, 1);
|
2014-09-25 22:44:45 +08:00
|
|
|
#ifdef CONFIG_QUOTA
|
|
|
|
memset(&ei->i_dquot, 0, sizeof(ei->i_dquot));
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return &ei->vfs_inode;
|
|
|
|
}
|
|
|
|
|
2019-04-16 07:27:18 +08:00
|
|
|
static void ext2_free_in_core_inode(struct inode *inode)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
kmem_cache_free(ext2_inode_cachep, EXT2_I(inode));
|
|
|
|
}
|
|
|
|
|
2008-07-26 10:45:34 +08:00
|
|
|
static void init_once(void *foo)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct ext2_inode_info *ei = (struct ext2_inode_info *) foo;
|
|
|
|
|
2007-05-17 13:10:57 +08:00
|
|
|
rwlock_init(&ei->i_meta_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef CONFIG_EXT2_FS_XATTR
|
2007-05-17 13:10:57 +08:00
|
|
|
init_rwsem(&ei->xattr_sem);
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
2007-10-17 14:30:46 +08:00
|
|
|
mutex_init(&ei->truncate_mutex);
|
2007-05-17 13:10:57 +08:00
|
|
|
inode_init_once(&ei->vfs_inode);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2007-07-20 09:11:58 +08:00
|
|
|
|
2014-02-01 16:02:02 +08:00
|
|
|
static int __init init_inodecache(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
ext2: Define usercopy region in ext2_inode_cache slab cache
The ext2 symlink pathnames, stored in struct ext2_inode_info.i_data and
therefore contained in the ext2_inode_cache slab cache, need to be copied
to/from userspace.
cache object allocation:
fs/ext2/super.c:
ext2_alloc_inode(...):
struct ext2_inode_info *ei;
...
ei = kmem_cache_alloc(ext2_inode_cachep, GFP_NOFS);
...
return &ei->vfs_inode;
fs/ext2/ext2.h:
EXT2_I(struct inode *inode):
return container_of(inode, struct ext2_inode_info, vfs_inode);
fs/ext2/namei.c:
ext2_symlink(...):
...
inode->i_link = (char *)&EXT2_I(inode)->i_data;
example usage trace:
readlink_copy+0x43/0x70
vfs_readlink+0x62/0x110
SyS_readlinkat+0x100/0x130
fs/namei.c:
readlink_copy(..., link):
...
copy_to_user(..., link, len);
(inlined into vfs_readlink)
generic_readlink(dentry, ...):
struct inode *inode = d_inode(dentry);
const char *link = inode->i_link;
...
readlink_copy(..., link);
In support of usercopy hardening, this patch defines a region in the
ext2_inode_cache slab cache in which userspace copy operations are
allowed.
This region is known as the slab cache's usercopy region. Slab caches
can now check that each dynamically sized copy operation involving
cache-managed memory falls entirely within the slab's usercopy region.
This patch is modified from Brad Spengler/PaX Team's PAX_USERCOPY
whitelisting code in the last public patch of grsecurity/PaX based on my
understanding of the code. Changes or omissions from the original code are
mine and don't reflect the original grsecurity/PaX code.
Signed-off-by: David Windsor <dave@nullcore.net>
[kees: adjust commit log, provide usage trace]
Cc: Jan Kara <jack@suse.com>
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Jan Kara <jack@suse.cz>
2017-06-11 10:50:35 +08:00
|
|
|
ext2_inode_cachep = kmem_cache_create_usercopy("ext2_inode_cache",
|
|
|
|
sizeof(struct ext2_inode_info), 0,
|
|
|
|
(SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|
|
|
|
|
SLAB_ACCOUNT),
|
|
|
|
offsetof(struct ext2_inode_info, i_data),
|
|
|
|
sizeof_field(struct ext2_inode_info, i_data),
|
|
|
|
init_once);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ext2_inode_cachep == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void destroy_inodecache(void)
|
|
|
|
{
|
2012-09-26 09:33:07 +08:00
|
|
|
/*
|
|
|
|
* Make sure all delayed rcu free inodes are flushed before we
|
|
|
|
* destroy cache.
|
|
|
|
*/
|
|
|
|
rcu_barrier();
|
2006-09-27 16:49:40 +08:00
|
|
|
kmem_cache_destroy(ext2_inode_cachep);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2011-12-09 10:32:45 +08:00
|
|
|
static int ext2_show_options(struct seq_file *seq, struct dentry *root)
|
2005-09-07 06:16:54 +08:00
|
|
|
{
|
2011-12-09 10:32:45 +08:00
|
|
|
struct super_block *sb = root->d_sb;
|
2007-10-17 14:26:26 +08:00
|
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
|
|
|
struct ext2_super_block *es = sbi->s_es;
|
|
|
|
unsigned long def_mount_opts;
|
2005-09-07 06:16:54 +08:00
|
|
|
|
2010-04-14 20:38:38 +08:00
|
|
|
spin_lock(&sbi->s_lock);
|
2007-10-17 14:26:26 +08:00
|
|
|
def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
|
|
|
|
|
|
|
|
if (sbi->s_sb_block != 1)
|
|
|
|
seq_printf(seq, ",sb=%lu", sbi->s_sb_block);
|
|
|
|
if (test_opt(sb, MINIX_DF))
|
|
|
|
seq_puts(seq, ",minixdf");
|
|
|
|
if (test_opt(sb, GRPID))
|
2005-09-07 06:16:54 +08:00
|
|
|
seq_puts(seq, ",grpid");
|
2007-10-17 14:26:26 +08:00
|
|
|
if (!test_opt(sb, GRPID) && (def_mount_opts & EXT2_DEFM_BSDGROUPS))
|
|
|
|
seq_puts(seq, ",nogrpid");
|
2012-02-08 07:39:12 +08:00
|
|
|
if (!uid_eq(sbi->s_resuid, make_kuid(&init_user_ns, EXT2_DEF_RESUID)) ||
|
2007-10-17 14:26:26 +08:00
|
|
|
le16_to_cpu(es->s_def_resuid) != EXT2_DEF_RESUID) {
|
2012-02-08 07:39:12 +08:00
|
|
|
seq_printf(seq, ",resuid=%u",
|
|
|
|
from_kuid_munged(&init_user_ns, sbi->s_resuid));
|
2007-10-17 14:26:26 +08:00
|
|
|
}
|
2012-02-08 07:39:12 +08:00
|
|
|
if (!gid_eq(sbi->s_resgid, make_kgid(&init_user_ns, EXT2_DEF_RESGID)) ||
|
2007-10-17 14:26:26 +08:00
|
|
|
le16_to_cpu(es->s_def_resgid) != EXT2_DEF_RESGID) {
|
2012-02-08 07:39:12 +08:00
|
|
|
seq_printf(seq, ",resgid=%u",
|
|
|
|
from_kgid_munged(&init_user_ns, sbi->s_resgid));
|
2007-10-17 14:26:26 +08:00
|
|
|
}
|
2008-02-06 17:36:17 +08:00
|
|
|
if (test_opt(sb, ERRORS_RO)) {
|
2007-10-17 14:26:26 +08:00
|
|
|
int def_errors = le16_to_cpu(es->s_errors);
|
|
|
|
|
|
|
|
if (def_errors == EXT2_ERRORS_PANIC ||
|
2008-02-06 17:36:17 +08:00
|
|
|
def_errors == EXT2_ERRORS_CONTINUE) {
|
|
|
|
seq_puts(seq, ",errors=remount-ro");
|
2007-10-17 14:26:26 +08:00
|
|
|
}
|
|
|
|
}
|
2008-02-06 17:36:17 +08:00
|
|
|
if (test_opt(sb, ERRORS_CONT))
|
|
|
|
seq_puts(seq, ",errors=continue");
|
2007-10-17 14:26:26 +08:00
|
|
|
if (test_opt(sb, ERRORS_PANIC))
|
|
|
|
seq_puts(seq, ",errors=panic");
|
|
|
|
if (test_opt(sb, NO_UID32))
|
|
|
|
seq_puts(seq, ",nouid32");
|
|
|
|
if (test_opt(sb, DEBUG))
|
|
|
|
seq_puts(seq, ",debug");
|
|
|
|
if (test_opt(sb, OLDALLOC))
|
|
|
|
seq_puts(seq, ",oldalloc");
|
|
|
|
|
|
|
|
#ifdef CONFIG_EXT2_FS_XATTR
|
|
|
|
if (test_opt(sb, XATTR_USER))
|
|
|
|
seq_puts(seq, ",user_xattr");
|
|
|
|
if (!test_opt(sb, XATTR_USER) &&
|
|
|
|
(def_mount_opts & EXT2_DEFM_XATTR_USER)) {
|
|
|
|
seq_puts(seq, ",nouser_xattr");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_EXT2_FS_POSIX_ACL
|
|
|
|
if (test_opt(sb, POSIX_ACL))
|
|
|
|
seq_puts(seq, ",acl");
|
|
|
|
if (!test_opt(sb, POSIX_ACL) && (def_mount_opts & EXT2_DEFM_ACL))
|
|
|
|
seq_puts(seq, ",noacl");
|
|
|
|
#endif
|
|
|
|
|
2019-05-20 13:45:03 +08:00
|
|
|
if (test_opt(sb, USRQUOTA))
|
2005-09-07 06:16:54 +08:00
|
|
|
seq_puts(seq, ",usrquota");
|
|
|
|
|
2019-05-20 13:45:03 +08:00
|
|
|
if (test_opt(sb, GRPQUOTA))
|
2005-09-07 06:16:54 +08:00
|
|
|
seq_puts(seq, ",grpquota");
|
|
|
|
|
2019-05-20 13:45:03 +08:00
|
|
|
if (test_opt(sb, XIP))
|
2006-02-03 19:04:25 +08:00
|
|
|
seq_puts(seq, ",xip");
|
2018-09-24 14:10:15 +08:00
|
|
|
|
2019-05-20 13:45:03 +08:00
|
|
|
if (test_opt(sb, DAX))
|
2015-02-17 07:59:31 +08:00
|
|
|
seq_puts(seq, ",dax");
|
2006-02-03 19:04:25 +08:00
|
|
|
|
2008-02-08 20:21:42 +08:00
|
|
|
if (!test_opt(sb, RESERVATION))
|
|
|
|
seq_puts(seq, ",noreservation");
|
|
|
|
|
2010-04-14 20:38:38 +08:00
|
|
|
spin_unlock(&sbi->s_lock);
|
2005-09-07 06:16:54 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef CONFIG_QUOTA
|
|
|
|
static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data, size_t len, loff_t off);
|
|
|
|
static ssize_t ext2_quota_write(struct super_block *sb, int type, const char *data, size_t len, loff_t off);
|
2017-04-06 23:02:09 +08:00
|
|
|
static int ext2_quota_on(struct super_block *sb, int type, int format_id,
|
|
|
|
const struct path *path);
|
2014-09-25 22:44:45 +08:00
|
|
|
static struct dquot **ext2_get_dquots(struct inode *inode)
|
|
|
|
{
|
|
|
|
return EXT2_I(inode)->i_dquot;
|
|
|
|
}
|
2017-04-06 23:02:09 +08:00
|
|
|
|
|
|
|
static const struct quotactl_ops ext2_quotactl_ops = {
|
|
|
|
.quota_on = ext2_quota_on,
|
|
|
|
.quota_off = ext2_quota_off,
|
|
|
|
.quota_sync = dquot_quota_sync,
|
|
|
|
.get_state = dquot_get_state,
|
|
|
|
.set_info = dquot_set_dqinfo,
|
|
|
|
.get_dqblk = dquot_get_dqblk,
|
|
|
|
.set_dqblk = dquot_set_dqblk,
|
|
|
|
.get_nextdqblk = dquot_get_next_dqblk,
|
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
2007-02-12 16:55:41 +08:00
|
|
|
static const struct super_operations ext2_sops = {
|
2005-04-17 06:20:36 +08:00
|
|
|
.alloc_inode = ext2_alloc_inode,
|
2019-04-16 07:27:18 +08:00
|
|
|
.free_inode = ext2_free_in_core_inode,
|
2005-04-17 06:20:36 +08:00
|
|
|
.write_inode = ext2_write_inode,
|
2010-06-05 11:32:28 +08:00
|
|
|
.evict_inode = ext2_evict_inode,
|
2005-04-17 06:20:36 +08:00
|
|
|
.put_super = ext2_put_super,
|
2009-06-08 16:04:17 +08:00
|
|
|
.sync_fs = ext2_sync_fs,
|
2012-06-12 22:20:46 +08:00
|
|
|
.freeze_fs = ext2_freeze,
|
|
|
|
.unfreeze_fs = ext2_unfreeze,
|
2005-04-17 06:20:36 +08:00
|
|
|
.statfs = ext2_statfs,
|
|
|
|
.remount_fs = ext2_remount,
|
2005-09-07 06:16:54 +08:00
|
|
|
.show_options = ext2_show_options,
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef CONFIG_QUOTA
|
|
|
|
.quota_read = ext2_quota_read,
|
|
|
|
.quota_write = ext2_quota_write,
|
2014-09-25 22:44:45 +08:00
|
|
|
.get_dquots = ext2_get_dquots,
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2007-10-22 07:42:07 +08:00
|
|
|
static struct inode *ext2_nfs_get_inode(struct super_block *sb,
|
|
|
|
u64 ino, u32 generation)
|
2006-09-17 03:15:37 +08:00
|
|
|
{
|
|
|
|
struct inode *inode;
|
|
|
|
|
|
|
|
if (ino < EXT2_FIRST_INO(sb) && ino != EXT2_ROOT_INO)
|
|
|
|
return ERR_PTR(-ESTALE);
|
|
|
|
if (ino > le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count))
|
|
|
|
return ERR_PTR(-ESTALE);
|
|
|
|
|
2011-08-30 23:32:50 +08:00
|
|
|
/*
|
|
|
|
* ext2_iget isn't quite right if the inode is currently unallocated!
|
|
|
|
* However ext2_iget currently does appropriate checks to handle stale
|
|
|
|
* inodes so everything is OK.
|
2006-09-17 03:15:37 +08:00
|
|
|
*/
|
2008-02-07 16:15:35 +08:00
|
|
|
inode = ext2_iget(sb, ino);
|
|
|
|
if (IS_ERR(inode))
|
|
|
|
return ERR_CAST(inode);
|
|
|
|
if (generation && inode->i_generation != generation) {
|
2006-09-17 03:15:37 +08:00
|
|
|
/* we didn't find the right inode.. */
|
|
|
|
iput(inode);
|
|
|
|
return ERR_PTR(-ESTALE);
|
|
|
|
}
|
2007-10-22 07:42:07 +08:00
|
|
|
return inode;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct dentry *ext2_fh_to_dentry(struct super_block *sb, struct fid *fid,
|
|
|
|
int fh_len, int fh_type)
|
|
|
|
{
|
|
|
|
return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
|
|
|
|
ext2_nfs_get_inode);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct dentry *ext2_fh_to_parent(struct super_block *sb, struct fid *fid,
|
|
|
|
int fh_len, int fh_type)
|
|
|
|
{
|
|
|
|
return generic_fh_to_parent(sb, fid, fh_len, fh_type,
|
|
|
|
ext2_nfs_get_inode);
|
2006-09-17 03:15:37 +08:00
|
|
|
}
|
|
|
|
|
2007-10-22 07:42:17 +08:00
|
|
|
static const struct export_operations ext2_export_ops = {
|
2007-10-22 07:42:07 +08:00
|
|
|
.fh_to_dentry = ext2_fh_to_dentry,
|
|
|
|
.fh_to_parent = ext2_fh_to_parent,
|
2005-04-17 06:20:36 +08:00
|
|
|
.get_parent = ext2_get_parent,
|
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned long get_sb_block(void **data)
|
|
|
|
{
|
|
|
|
unsigned long sb_block;
|
|
|
|
char *options = (char *) *data;
|
|
|
|
|
|
|
|
if (!options || strncmp(options, "sb=", 3) != 0)
|
|
|
|
return 1; /* Default location */
|
|
|
|
options += 3;
|
|
|
|
sb_block = simple_strtoul(options, &options, 0);
|
|
|
|
if (*options && *options != ',') {
|
|
|
|
printk("EXT2-fs: Invalid sb specification: %s\n",
|
|
|
|
(char *) *data);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (*options == ',')
|
|
|
|
options++;
|
|
|
|
*data = (void *) options;
|
|
|
|
return sb_block;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum {
|
|
|
|
Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,
|
2005-09-07 06:16:54 +08:00
|
|
|
Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic,
|
2020-06-19 15:31:44 +08:00
|
|
|
Opt_err_ro, Opt_nouid32, Opt_debug,
|
2005-09-07 06:16:54 +08:00
|
|
|
Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
|
2015-02-17 07:59:31 +08:00
|
|
|
Opt_acl, Opt_noacl, Opt_xip, Opt_dax, Opt_ignore, Opt_err, Opt_quota,
|
2007-10-17 14:30:46 +08:00
|
|
|
Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2008-10-13 17:46:57 +08:00
|
|
|
static const match_table_t tokens = {
|
2005-04-17 06:20:36 +08:00
|
|
|
{Opt_bsd_df, "bsddf"},
|
|
|
|
{Opt_minix_df, "minixdf"},
|
|
|
|
{Opt_grpid, "grpid"},
|
|
|
|
{Opt_grpid, "bsdgroups"},
|
|
|
|
{Opt_nogrpid, "nogrpid"},
|
|
|
|
{Opt_nogrpid, "sysvgroups"},
|
|
|
|
{Opt_resgid, "resgid=%u"},
|
|
|
|
{Opt_resuid, "resuid=%u"},
|
|
|
|
{Opt_sb, "sb=%u"},
|
|
|
|
{Opt_err_cont, "errors=continue"},
|
|
|
|
{Opt_err_panic, "errors=panic"},
|
|
|
|
{Opt_err_ro, "errors=remount-ro"},
|
|
|
|
{Opt_nouid32, "nouid32"},
|
|
|
|
{Opt_debug, "debug"},
|
|
|
|
{Opt_oldalloc, "oldalloc"},
|
|
|
|
{Opt_orlov, "orlov"},
|
|
|
|
{Opt_nobh, "nobh"},
|
|
|
|
{Opt_user_xattr, "user_xattr"},
|
|
|
|
{Opt_nouser_xattr, "nouser_xattr"},
|
|
|
|
{Opt_acl, "acl"},
|
|
|
|
{Opt_noacl, "noacl"},
|
2005-06-24 13:05:26 +08:00
|
|
|
{Opt_xip, "xip"},
|
2015-02-17 07:59:31 +08:00
|
|
|
{Opt_dax, "dax"},
|
2005-09-07 06:16:54 +08:00
|
|
|
{Opt_grpquota, "grpquota"},
|
2005-04-17 06:20:36 +08:00
|
|
|
{Opt_ignore, "noquota"},
|
2005-09-07 06:16:54 +08:00
|
|
|
{Opt_quota, "quota"},
|
|
|
|
{Opt_usrquota, "usrquota"},
|
2007-10-17 14:30:46 +08:00
|
|
|
{Opt_reservation, "reservation"},
|
|
|
|
{Opt_noreservation, "noreservation"},
|
2005-04-17 06:20:36 +08:00
|
|
|
{Opt_err, NULL}
|
|
|
|
};
|
|
|
|
|
2017-10-09 22:34:58 +08:00
|
|
|
static int parse_options(char *options, struct super_block *sb,
|
|
|
|
struct ext2_mount_options *opts)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
char *p;
|
2005-04-17 06:20:36 +08:00
|
|
|
substring_t args[MAX_OPT_ARGS];
|
|
|
|
int option;
|
2012-02-08 07:39:12 +08:00
|
|
|
kuid_t uid;
|
|
|
|
kgid_t gid;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (!options)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
while ((p = strsep (&options, ",")) != NULL) {
|
|
|
|
int token;
|
|
|
|
if (!*p)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
token = match_token(p, tokens, args);
|
|
|
|
switch (token) {
|
|
|
|
case Opt_bsd_df:
|
2017-10-09 22:34:58 +08:00
|
|
|
clear_opt (opts->s_mount_opt, MINIX_DF);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case Opt_minix_df:
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt (opts->s_mount_opt, MINIX_DF);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case Opt_grpid:
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt (opts->s_mount_opt, GRPID);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case Opt_nogrpid:
|
2017-10-09 22:34:58 +08:00
|
|
|
clear_opt (opts->s_mount_opt, GRPID);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case Opt_resuid:
|
|
|
|
if (match_int(&args[0], &option))
|
|
|
|
return 0;
|
2012-02-08 07:39:12 +08:00
|
|
|
uid = make_kuid(current_user_ns(), option);
|
|
|
|
if (!uid_valid(uid)) {
|
|
|
|
ext2_msg(sb, KERN_ERR, "Invalid uid value %d", option);
|
2012-10-09 13:44:36 +08:00
|
|
|
return 0;
|
2012-02-08 07:39:12 +08:00
|
|
|
|
|
|
|
}
|
2017-10-09 22:34:58 +08:00
|
|
|
opts->s_resuid = uid;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case Opt_resgid:
|
|
|
|
if (match_int(&args[0], &option))
|
|
|
|
return 0;
|
2012-02-08 07:39:12 +08:00
|
|
|
gid = make_kgid(current_user_ns(), option);
|
|
|
|
if (!gid_valid(gid)) {
|
|
|
|
ext2_msg(sb, KERN_ERR, "Invalid gid value %d", option);
|
2012-10-09 13:44:36 +08:00
|
|
|
return 0;
|
2012-02-08 07:39:12 +08:00
|
|
|
}
|
2017-10-09 22:34:58 +08:00
|
|
|
opts->s_resgid = gid;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case Opt_sb:
|
|
|
|
/* handled by get_sb_block() instead of here */
|
|
|
|
/* *sb_block = match_int(&args[0]); */
|
|
|
|
break;
|
|
|
|
case Opt_err_panic:
|
2017-10-09 22:34:58 +08:00
|
|
|
clear_opt (opts->s_mount_opt, ERRORS_CONT);
|
|
|
|
clear_opt (opts->s_mount_opt, ERRORS_RO);
|
|
|
|
set_opt (opts->s_mount_opt, ERRORS_PANIC);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case Opt_err_ro:
|
2017-10-09 22:34:58 +08:00
|
|
|
clear_opt (opts->s_mount_opt, ERRORS_CONT);
|
|
|
|
clear_opt (opts->s_mount_opt, ERRORS_PANIC);
|
|
|
|
set_opt (opts->s_mount_opt, ERRORS_RO);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case Opt_err_cont:
|
2017-10-09 22:34:58 +08:00
|
|
|
clear_opt (opts->s_mount_opt, ERRORS_RO);
|
|
|
|
clear_opt (opts->s_mount_opt, ERRORS_PANIC);
|
|
|
|
set_opt (opts->s_mount_opt, ERRORS_CONT);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case Opt_nouid32:
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt (opts->s_mount_opt, NO_UID32);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case Opt_debug:
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt (opts->s_mount_opt, DEBUG);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case Opt_oldalloc:
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt (opts->s_mount_opt, OLDALLOC);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case Opt_orlov:
|
2017-10-09 22:34:58 +08:00
|
|
|
clear_opt (opts->s_mount_opt, OLDALLOC);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case Opt_nobh:
|
2022-06-13 13:37:11 +08:00
|
|
|
ext2_msg(sb, KERN_INFO,
|
|
|
|
"nobh option not supported");
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
#ifdef CONFIG_EXT2_FS_XATTR
|
|
|
|
case Opt_user_xattr:
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt (opts->s_mount_opt, XATTR_USER);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case Opt_nouser_xattr:
|
2017-10-09 22:34:58 +08:00
|
|
|
clear_opt (opts->s_mount_opt, XATTR_USER);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
#else
|
|
|
|
case Opt_user_xattr:
|
|
|
|
case Opt_nouser_xattr:
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_INFO, "(no)user_xattr options"
|
|
|
|
"not supported");
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_EXT2_FS_POSIX_ACL
|
|
|
|
case Opt_acl:
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt(opts->s_mount_opt, POSIX_ACL);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case Opt_noacl:
|
2017-10-09 22:34:58 +08:00
|
|
|
clear_opt(opts->s_mount_opt, POSIX_ACL);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
#else
|
|
|
|
case Opt_acl:
|
|
|
|
case Opt_noacl:
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_INFO,
|
|
|
|
"(no)acl options not supported");
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
#endif
|
2005-06-24 13:05:26 +08:00
|
|
|
case Opt_xip:
|
2015-02-17 07:59:31 +08:00
|
|
|
ext2_msg(sb, KERN_INFO, "use dax instead of xip");
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt(opts->s_mount_opt, XIP);
|
2020-08-24 06:36:59 +08:00
|
|
|
fallthrough;
|
2015-02-17 07:59:31 +08:00
|
|
|
case Opt_dax:
|
2015-02-17 07:59:25 +08:00
|
|
|
#ifdef CONFIG_FS_DAX
|
2015-09-30 03:48:11 +08:00
|
|
|
ext2_msg(sb, KERN_WARNING,
|
|
|
|
"DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt(opts->s_mount_opt, DAX);
|
2005-06-24 13:05:26 +08:00
|
|
|
#else
|
2015-02-17 07:59:31 +08:00
|
|
|
ext2_msg(sb, KERN_INFO, "dax option not supported");
|
2005-06-24 13:05:26 +08:00
|
|
|
#endif
|
|
|
|
break;
|
2005-09-07 06:16:54 +08:00
|
|
|
|
|
|
|
#if defined(CONFIG_QUOTA)
|
|
|
|
case Opt_quota:
|
|
|
|
case Opt_usrquota:
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt(opts->s_mount_opt, USRQUOTA);
|
2005-09-07 06:16:54 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Opt_grpquota:
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt(opts->s_mount_opt, GRPQUOTA);
|
2005-09-07 06:16:54 +08:00
|
|
|
break;
|
|
|
|
#else
|
|
|
|
case Opt_quota:
|
|
|
|
case Opt_usrquota:
|
|
|
|
case Opt_grpquota:
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_INFO,
|
|
|
|
"quota operations not supported");
|
2005-09-07 06:16:54 +08:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2007-10-17 14:30:46 +08:00
|
|
|
case Opt_reservation:
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt(opts->s_mount_opt, RESERVATION);
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_INFO, "reservations ON");
|
2007-10-17 14:30:46 +08:00
|
|
|
break;
|
|
|
|
case Opt_noreservation:
|
2017-10-09 22:34:58 +08:00
|
|
|
clear_opt(opts->s_mount_opt, RESERVATION);
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_INFO, "reservations OFF");
|
2007-10-17 14:30:46 +08:00
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
case Opt_ignore:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ext2_setup_super (struct super_block * sb,
|
|
|
|
struct ext2_super_block * es,
|
|
|
|
int read_only)
|
|
|
|
{
|
|
|
|
int res = 0;
|
|
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
|
|
|
|
|
|
|
if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) {
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR,
|
|
|
|
"error: revision level too high, "
|
|
|
|
"forcing read-only mode");
|
2017-11-28 05:05:09 +08:00
|
|
|
res = SB_RDONLY;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
if (read_only)
|
|
|
|
return res;
|
|
|
|
if (!(sbi->s_mount_state & EXT2_VALID_FS))
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_WARNING,
|
|
|
|
"warning: mounting unchecked fs, "
|
|
|
|
"running e2fsck is recommended");
|
2005-04-17 06:20:36 +08:00
|
|
|
else if ((sbi->s_mount_state & EXT2_ERROR_FS))
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_WARNING,
|
|
|
|
"warning: mounting fs with errors, "
|
|
|
|
"running e2fsck is recommended");
|
2005-04-17 06:20:36 +08:00
|
|
|
else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
|
|
|
|
le16_to_cpu(es->s_mnt_count) >=
|
|
|
|
(unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_WARNING,
|
|
|
|
"warning: maximal mount count reached, "
|
|
|
|
"running e2fsck is recommended");
|
2005-04-17 06:20:36 +08:00
|
|
|
else if (le32_to_cpu(es->s_checkinterval) &&
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
(le32_to_cpu(es->s_lastcheck) +
|
2018-06-20 22:31:40 +08:00
|
|
|
le32_to_cpu(es->s_checkinterval) <=
|
|
|
|
ktime_get_real_seconds()))
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_WARNING,
|
|
|
|
"warning: checktime reached, "
|
|
|
|
"running e2fsck is recommended");
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!le16_to_cpu(es->s_max_mnt_count))
|
|
|
|
es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT);
|
2008-04-28 17:15:59 +08:00
|
|
|
le16_add_cpu(&es->s_mnt_count, 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (test_opt (sb, DEBUG))
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_INFO, "%s, %s, bs=%lu, fs=%lu, gc=%lu, "
|
|
|
|
"bpg=%lu, ipg=%lu, mo=%04lx]",
|
2005-04-17 06:20:36 +08:00
|
|
|
EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize,
|
|
|
|
sbi->s_frag_size,
|
|
|
|
sbi->s_groups_count,
|
|
|
|
EXT2_BLOCKS_PER_GROUP(sb),
|
|
|
|
EXT2_INODES_PER_GROUP(sb),
|
|
|
|
sbi->s_mount_opt);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2008-02-06 17:40:16 +08:00
|
|
|
static int ext2_check_descriptors(struct super_block *sb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
|
|
|
|
|
|
|
ext2_debug ("Checking group descriptors");
|
|
|
|
|
2008-02-06 17:40:16 +08:00
|
|
|
for (i = 0; i < sbi->s_groups_count; i++) {
|
|
|
|
struct ext2_group_desc *gdp = ext2_get_group_desc(sb, i, NULL);
|
2008-04-28 17:16:01 +08:00
|
|
|
ext2_fsblk_t first_block = ext2_group_first_block_no(sb, i);
|
2019-11-04 19:40:33 +08:00
|
|
|
ext2_fsblk_t last_block = ext2_group_last_block_no(sb, i);
|
2006-09-27 16:49:30 +08:00
|
|
|
|
|
|
|
if (le32_to_cpu(gdp->bg_block_bitmap) < first_block ||
|
|
|
|
le32_to_cpu(gdp->bg_block_bitmap) > last_block)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
ext2_error (sb, "ext2_check_descriptors",
|
|
|
|
"Block bitmap for group %d"
|
|
|
|
" not in group (block %lu)!",
|
|
|
|
i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap));
|
|
|
|
return 0;
|
|
|
|
}
|
2006-09-27 16:49:30 +08:00
|
|
|
if (le32_to_cpu(gdp->bg_inode_bitmap) < first_block ||
|
|
|
|
le32_to_cpu(gdp->bg_inode_bitmap) > last_block)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
ext2_error (sb, "ext2_check_descriptors",
|
|
|
|
"Inode bitmap for group %d"
|
|
|
|
" not in group (block %lu)!",
|
|
|
|
i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap));
|
|
|
|
return 0;
|
|
|
|
}
|
2006-09-27 16:49:30 +08:00
|
|
|
if (le32_to_cpu(gdp->bg_inode_table) < first_block ||
|
2007-07-27 01:41:11 +08:00
|
|
|
le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group - 1 >
|
2006-09-27 16:49:30 +08:00
|
|
|
last_block)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
ext2_error (sb, "ext2_check_descriptors",
|
|
|
|
"Inode table for group %d"
|
|
|
|
" not in group (block %lu)!",
|
|
|
|
i, (unsigned long) le32_to_cpu(gdp->bg_inode_table));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Maximal file size. There is a direct, and {,double-,triple-}indirect
|
|
|
|
* block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks.
|
|
|
|
* We need to be 1 filesystem block less than the 2^32 sector limit.
|
|
|
|
*/
|
|
|
|
static loff_t ext2_max_size(int bits)
|
|
|
|
{
|
|
|
|
loff_t res = EXT2_NDIR_BLOCKS;
|
2008-01-29 12:58:26 +08:00
|
|
|
int meta_blocks;
|
2019-01-30 00:17:24 +08:00
|
|
|
unsigned int upper_limit;
|
|
|
|
unsigned int ppb = 1 << (bits-2);
|
2008-01-29 12:58:26 +08:00
|
|
|
|
|
|
|
/* This is calculated to be the largest file size for a
|
|
|
|
* dense, file such that the total number of
|
2005-04-17 06:20:36 +08:00
|
|
|
* sectors in the file, including data and all indirect blocks,
|
2008-01-29 12:58:26 +08:00
|
|
|
* does not exceed 2^32 -1
|
|
|
|
* __u32 i_blocks representing the total number of
|
|
|
|
* 512 bytes blocks of the file
|
|
|
|
*/
|
|
|
|
upper_limit = (1LL << 32) - 1;
|
|
|
|
|
|
|
|
/* total blocks in file system block size */
|
|
|
|
upper_limit >>= (bits - 9);
|
|
|
|
|
2019-01-30 00:17:24 +08:00
|
|
|
/* Compute how many blocks we can address by block tree */
|
|
|
|
res += 1LL << (bits-2);
|
|
|
|
res += 1LL << (2*(bits-2));
|
|
|
|
res += 1LL << (3*(bits-2));
|
2022-02-12 13:05:32 +08:00
|
|
|
/* Compute how many metadata blocks are needed */
|
|
|
|
meta_blocks = 1;
|
|
|
|
meta_blocks += 1 + ppb;
|
|
|
|
meta_blocks += 1 + ppb + ppb * ppb;
|
2019-01-30 00:17:24 +08:00
|
|
|
/* Does block tree limit file size? */
|
2022-02-12 13:05:32 +08:00
|
|
|
if (res + meta_blocks <= upper_limit)
|
2019-01-30 00:17:24 +08:00
|
|
|
goto check_lfs;
|
2008-01-29 12:58:26 +08:00
|
|
|
|
2019-01-30 00:17:24 +08:00
|
|
|
res = upper_limit;
|
|
|
|
/* How many metadata blocks are needed for addressing upper_limit? */
|
|
|
|
upper_limit -= EXT2_NDIR_BLOCKS;
|
2008-01-29 12:58:26 +08:00
|
|
|
/* indirect blocks */
|
|
|
|
meta_blocks = 1;
|
2019-01-30 00:17:24 +08:00
|
|
|
upper_limit -= ppb;
|
2008-01-29 12:58:26 +08:00
|
|
|
/* double indirect blocks */
|
2019-01-30 00:17:24 +08:00
|
|
|
if (upper_limit < ppb * ppb) {
|
|
|
|
meta_blocks += 1 + DIV_ROUND_UP(upper_limit, ppb);
|
|
|
|
res -= meta_blocks;
|
|
|
|
goto check_lfs;
|
|
|
|
}
|
|
|
|
meta_blocks += 1 + ppb;
|
|
|
|
upper_limit -= ppb * ppb;
|
|
|
|
/* tripple indirect blocks for the rest */
|
|
|
|
meta_blocks += 1 + DIV_ROUND_UP(upper_limit, ppb) +
|
|
|
|
DIV_ROUND_UP(upper_limit, ppb*ppb);
|
|
|
|
res -= meta_blocks;
|
|
|
|
check_lfs:
|
2005-04-17 06:20:36 +08:00
|
|
|
res <<= bits;
|
2008-01-29 12:58:26 +08:00
|
|
|
if (res > MAX_LFS_FILESIZE)
|
|
|
|
res = MAX_LFS_FILESIZE;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long descriptor_loc(struct super_block *sb,
|
|
|
|
unsigned long logic_sb_block,
|
|
|
|
int nr)
|
|
|
|
{
|
|
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
2008-04-28 17:16:01 +08:00
|
|
|
unsigned long bg, first_meta_bg;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
|
|
|
|
|
|
|
|
if (!EXT2_HAS_INCOMPAT_FEATURE(sb, EXT2_FEATURE_INCOMPAT_META_BG) ||
|
|
|
|
nr < first_meta_bg)
|
|
|
|
return (logic_sb_block + nr + 1);
|
|
|
|
bg = sbi->s_desc_per_block * nr;
|
2008-04-28 17:16:01 +08:00
|
|
|
|
2019-11-16 06:49:00 +08:00
|
|
|
return ext2_group_first_block_no(sb, bg) + ext2_bg_has_super(sb, bg);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ext2_fill_super(struct super_block *sb, void *data, int silent)
|
|
|
|
{
|
|
|
|
struct buffer_head * bh;
|
|
|
|
struct ext2_sb_info * sbi;
|
|
|
|
struct ext2_super_block * es;
|
|
|
|
struct inode *root;
|
|
|
|
unsigned long block;
|
|
|
|
unsigned long sb_block = get_sb_block(&data);
|
|
|
|
unsigned long logic_sb_block;
|
|
|
|
unsigned long offset = 0;
|
|
|
|
unsigned long def_mount_opts;
|
2018-02-26 17:45:12 +08:00
|
|
|
long ret = -ENOMEM;
|
2005-04-17 06:20:36 +08:00
|
|
|
int blocksize = BLOCK_SIZE;
|
|
|
|
int db_count;
|
|
|
|
int i, j;
|
|
|
|
__le32 features;
|
2007-10-17 14:25:45 +08:00
|
|
|
int err;
|
2017-10-09 22:34:58 +08:00
|
|
|
struct ext2_mount_options opts;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 16:49:37 +08:00
|
|
|
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!sbi)
|
2021-11-29 18:21:53 +08:00
|
|
|
return -ENOMEM;
|
2009-01-08 10:07:19 +08:00
|
|
|
|
|
|
|
sbi->s_blockgroup_lock =
|
|
|
|
kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
|
|
|
|
if (!sbi->s_blockgroup_lock) {
|
|
|
|
kfree(sbi);
|
2021-11-29 18:21:53 +08:00
|
|
|
return -ENOMEM;
|
2009-01-08 10:07:19 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
sb->s_fs_info = sbi;
|
2007-10-17 14:26:26 +08:00
|
|
|
sbi->s_sb_block = sb_block;
|
dax: introduce holder for dax_device
Patch series "v14 fsdax-rmap + v11 fsdax-reflink", v2.
The patchset fsdax-rmap is aimed to support shared pages tracking for
fsdax.
It moves owner tracking from dax_assocaite_entry() to pmem device driver,
by introducing an interface ->memory_failure() for struct pagemap. This
interface is called by memory_failure() in mm, and implemented by pmem
device.
Then call holder operations to find the filesystem which the corrupted
data located in, and call filesystem handler to track files or metadata
associated with this page.
Finally we are able to try to fix the corrupted data in filesystem and do
other necessary processing, such as killing processes who are using the
files affected.
The call trace is like this:
memory_failure()
|* fsdax case
|------------
|pgmap->ops->memory_failure() => pmem_pgmap_memory_failure()
| dax_holder_notify_failure() =>
| dax_device->holder_ops->notify_failure() =>
| - xfs_dax_notify_failure()
| |* xfs_dax_notify_failure()
| |--------------------------
| | xfs_rmap_query_range()
| | xfs_dax_failure_fn()
| | * corrupted on metadata
| | try to recover data, call xfs_force_shutdown()
| | * corrupted on file data
| | try to recover data, call mf_dax_kill_procs()
|* normal case
|-------------
|mf_generic_kill_procs()
The patchset fsdax-reflink attempts to add CoW support for fsdax, and
takes XFS, which has both reflink and fsdax features, as an example.
One of the key mechanisms needed to be implemented in fsdax is CoW. Copy
the data from srcmap before we actually write data to the destination
iomap. And we just copy range in which data won't be changed.
Another mechanism is range comparison. In page cache case, readpage() is
used to load data on disk to page cache in order to be able to compare
data. In fsdax case, readpage() does not work. So, we need another
compare data with direct access support.
With the two mechanisms implemented in fsdax, we are able to make reflink
and fsdax work together in XFS.
This patch (of 14):
To easily track filesystem from a pmem device, we introduce a holder for
dax_device structure, and also its operation. This holder is used to
remember who is using this dax_device:
- When it is the backend of a filesystem, the holder will be the
instance of this filesystem.
- When this pmem device is one of the targets in a mapped device, the
holder will be this mapped device. In this case, the mapped device
has its own dax_device and it will follow the first rule. So that we
can finally track to the filesystem we needed.
The holder and holder_ops will be set when filesystem is being mounted,
or an target device is being activated.
Link: https://lkml.kernel.org/r/20220603053738.1218681-1-ruansy.fnst@fujitsu.com
Link: https://lkml.kernel.org/r/20220603053738.1218681-2-ruansy.fnst@fujitsu.com
Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dan Williams <dan.j.wiliams@intel.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Jane Chu <jane.chu@oracle.com>
Cc: Goldwyn Rodrigues <rgoldwyn@suse.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Goldwyn Rodrigues <rgoldwyn@suse.com>
Cc: Ritesh Harjani <riteshh@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2022-06-03 13:37:25 +08:00
|
|
|
sbi->s_daxdev = fs_dax_get_by_bdev(sb->s_bdev, &sbi->s_dax_part_off,
|
|
|
|
NULL, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-04-14 20:38:38 +08:00
|
|
|
spin_lock_init(&sbi->s_lock);
|
2018-02-26 17:45:12 +08:00
|
|
|
ret = -EINVAL;
|
2010-04-14 20:38:38 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* See what the current blocksize for the device is, and
|
|
|
|
* use that as the blocksize. Otherwise (or if the blocksize
|
|
|
|
* is smaller than the default) use the default.
|
|
|
|
* This is important for devices that have a hardware
|
|
|
|
* sectorsize that is larger than the default.
|
|
|
|
*/
|
|
|
|
blocksize = sb_min_blocksize(sb, BLOCK_SIZE);
|
|
|
|
if (!blocksize) {
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR, "error: unable to set blocksize");
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed_sbi;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the superblock doesn't start on a hardware sector boundary,
|
|
|
|
* calculate the offset.
|
|
|
|
*/
|
|
|
|
if (blocksize != BLOCK_SIZE) {
|
|
|
|
logic_sb_block = (sb_block*BLOCK_SIZE) / blocksize;
|
|
|
|
offset = (sb_block*BLOCK_SIZE) % blocksize;
|
|
|
|
} else {
|
|
|
|
logic_sb_block = sb_block;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(bh = sb_bread(sb, logic_sb_block))) {
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR, "error: unable to read superblock");
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed_sbi;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Note: s_es must be initialized as soon as possible because
|
|
|
|
* some ext2 macro-instructions depend on its value
|
|
|
|
*/
|
|
|
|
es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
|
|
|
|
sbi->s_es = es;
|
|
|
|
sb->s_magic = le16_to_cpu(es->s_magic);
|
|
|
|
|
|
|
|
if (sb->s_magic != EXT2_SUPER_MAGIC)
|
|
|
|
goto cantfind_ext2;
|
|
|
|
|
2018-11-24 19:21:59 +08:00
|
|
|
opts.s_mount_opt = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Set defaults before we parse the mount options */
|
|
|
|
def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
|
|
|
|
if (def_mount_opts & EXT2_DEFM_DEBUG)
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt(opts.s_mount_opt, DEBUG);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (def_mount_opts & EXT2_DEFM_BSDGROUPS)
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt(opts.s_mount_opt, GRPID);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (def_mount_opts & EXT2_DEFM_UID16)
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt(opts.s_mount_opt, NO_UID32);
|
2007-02-10 17:46:13 +08:00
|
|
|
#ifdef CONFIG_EXT2_FS_XATTR
|
2005-04-17 06:20:36 +08:00
|
|
|
if (def_mount_opts & EXT2_DEFM_XATTR_USER)
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt(opts.s_mount_opt, XATTR_USER);
|
2007-02-10 17:46:13 +08:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_EXT2_FS_POSIX_ACL
|
2005-04-17 06:20:36 +08:00
|
|
|
if (def_mount_opts & EXT2_DEFM_ACL)
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt(opts.s_mount_opt, POSIX_ACL);
|
2007-02-10 17:46:13 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_PANIC)
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt(opts.s_mount_opt, ERRORS_PANIC);
|
2008-02-06 17:36:17 +08:00
|
|
|
else if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_CONTINUE)
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt(opts.s_mount_opt, ERRORS_CONT);
|
2008-02-06 17:36:17 +08:00
|
|
|
else
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt(opts.s_mount_opt, ERRORS_RO);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2017-10-09 22:34:58 +08:00
|
|
|
opts.s_resuid = make_kuid(&init_user_ns, le16_to_cpu(es->s_def_resuid));
|
|
|
|
opts.s_resgid = make_kgid(&init_user_ns, le16_to_cpu(es->s_def_resgid));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2017-10-09 22:34:58 +08:00
|
|
|
set_opt(opts.s_mount_opt, RESERVATION);
|
2007-10-17 14:30:46 +08:00
|
|
|
|
2017-10-09 22:34:58 +08:00
|
|
|
if (!parse_options((char *) data, sb, &opts))
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed_mount;
|
|
|
|
|
2017-10-09 22:34:58 +08:00
|
|
|
sbi->s_mount_opt = opts.s_mount_opt;
|
|
|
|
sbi->s_resuid = opts.s_resuid;
|
|
|
|
sbi->s_resgid = opts.s_resgid;
|
|
|
|
|
2017-11-28 05:05:09 +08:00
|
|
|
sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
|
2019-05-20 13:45:03 +08:00
|
|
|
(test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0);
|
2015-06-17 06:48:31 +08:00
|
|
|
sb->s_iflags |= SB_I_CGROUPWB;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV &&
|
|
|
|
(EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
|
|
|
|
EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
|
|
|
|
EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U)))
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_WARNING,
|
|
|
|
"warning: feature flags set on rev 0 fs, "
|
|
|
|
"running e2fsck is recommended");
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Check feature flags regardless of the revision level, since we
|
|
|
|
* previously didn't change the revision level when setting the flags,
|
|
|
|
* so there is a chance incompat flags are set on a rev 0 filesystem.
|
|
|
|
*/
|
|
|
|
features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP);
|
|
|
|
if (features) {
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR, "error: couldn't mount because of "
|
|
|
|
"unsupported optional features (%x)",
|
|
|
|
le32_to_cpu(features));
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed_mount;
|
|
|
|
}
|
2017-07-17 15:45:34 +08:00
|
|
|
if (!sb_rdonly(sb) && (features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR, "error: couldn't mount RDWR because of "
|
|
|
|
"unsupported optional features (%x)",
|
|
|
|
le32_to_cpu(features));
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed_mount;
|
|
|
|
}
|
|
|
|
|
|
|
|
blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
|
|
|
|
|
2019-05-20 13:45:03 +08:00
|
|
|
if (test_opt(sb, DAX)) {
|
2021-11-29 18:21:53 +08:00
|
|
|
if (!sbi->s_daxdev) {
|
2017-12-22 10:18:27 +08:00
|
|
|
ext2_msg(sb, KERN_ERR,
|
|
|
|
"DAX unsupported by block device. Turning off DAX.");
|
2019-05-20 13:45:03 +08:00
|
|
|
clear_opt(sbi->s_mount_opt, DAX);
|
2021-11-29 18:21:42 +08:00
|
|
|
} else if (blocksize != PAGE_SIZE) {
|
|
|
|
ext2_msg(sb, KERN_ERR, "unsupported blocksize for DAX\n");
|
|
|
|
clear_opt(sbi->s_mount_opt, DAX);
|
2017-12-22 10:18:27 +08:00
|
|
|
}
|
2005-06-24 13:05:26 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* If the blocksize doesn't match, re-read the thing.. */
|
|
|
|
if (sb->s_blocksize != blocksize) {
|
|
|
|
brelse(bh);
|
|
|
|
|
|
|
|
if (!sb_set_blocksize(sb, blocksize)) {
|
2011-05-05 10:44:04 +08:00
|
|
|
ext2_msg(sb, KERN_ERR,
|
|
|
|
"error: bad blocksize %d", blocksize);
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed_sbi;
|
|
|
|
}
|
|
|
|
|
|
|
|
logic_sb_block = (sb_block*BLOCK_SIZE) / blocksize;
|
|
|
|
offset = (sb_block*BLOCK_SIZE) % blocksize;
|
|
|
|
bh = sb_bread(sb, logic_sb_block);
|
|
|
|
if(!bh) {
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR, "error: couldn't read"
|
|
|
|
"superblock on 2nd try");
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed_sbi;
|
|
|
|
}
|
|
|
|
es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
|
|
|
|
sbi->s_es = es;
|
|
|
|
if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) {
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR, "error: magic mismatch");
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed_mount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sb->s_maxbytes = ext2_max_size(sb->s_blocksize_bits);
|
2012-02-07 01:45:27 +08:00
|
|
|
sb->s_max_links = EXT2_LINK_MAX;
|
2019-07-30 23:22:29 +08:00
|
|
|
sb->s_time_min = S32_MIN;
|
|
|
|
sb->s_time_max = S32_MAX;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV) {
|
|
|
|
sbi->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
|
|
|
|
sbi->s_first_ino = EXT2_GOOD_OLD_FIRST_INO;
|
|
|
|
} else {
|
|
|
|
sbi->s_inode_size = le16_to_cpu(es->s_inode_size);
|
|
|
|
sbi->s_first_ino = le32_to_cpu(es->s_first_ino);
|
|
|
|
if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) ||
|
2007-10-17 14:27:14 +08:00
|
|
|
!is_power_of_2(sbi->s_inode_size) ||
|
2005-04-17 06:20:36 +08:00
|
|
|
(sbi->s_inode_size > blocksize)) {
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR,
|
|
|
|
"error: unsupported inode size: %d",
|
2005-04-17 06:20:36 +08:00
|
|
|
sbi->s_inode_size);
|
|
|
|
goto failed_mount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sbi->s_frag_size = EXT2_MIN_FRAG_SIZE <<
|
|
|
|
le32_to_cpu(es->s_log_frag_size);
|
|
|
|
if (sbi->s_frag_size == 0)
|
|
|
|
goto cantfind_ext2;
|
|
|
|
sbi->s_frags_per_block = sb->s_blocksize / sbi->s_frag_size;
|
|
|
|
|
|
|
|
sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group);
|
|
|
|
sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group);
|
|
|
|
sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group);
|
|
|
|
|
|
|
|
sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb);
|
2006-08-27 16:23:43 +08:00
|
|
|
if (sbi->s_inodes_per_block == 0 || sbi->s_inodes_per_group == 0)
|
2005-04-17 06:20:36 +08:00
|
|
|
goto cantfind_ext2;
|
|
|
|
sbi->s_itb_per_group = sbi->s_inodes_per_group /
|
|
|
|
sbi->s_inodes_per_block;
|
|
|
|
sbi->s_desc_per_block = sb->s_blocksize /
|
|
|
|
sizeof (struct ext2_group_desc);
|
|
|
|
sbi->s_sbh = bh;
|
|
|
|
sbi->s_mount_state = le16_to_cpu(es->s_state);
|
|
|
|
sbi->s_addr_per_block_bits =
|
2006-12-08 18:37:49 +08:00
|
|
|
ilog2 (EXT2_ADDR_PER_BLOCK(sb));
|
2005-04-17 06:20:36 +08:00
|
|
|
sbi->s_desc_per_block_bits =
|
2006-12-08 18:37:49 +08:00
|
|
|
ilog2 (EXT2_DESC_PER_BLOCK(sb));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (sb->s_magic != EXT2_SUPER_MAGIC)
|
|
|
|
goto cantfind_ext2;
|
|
|
|
|
|
|
|
if (sb->s_blocksize != bh->b_size) {
|
|
|
|
if (!silent)
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR, "error: unsupported blocksize");
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed_mount;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sb->s_blocksize != sbi->s_frag_size) {
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR,
|
|
|
|
"error: fragsize %lu != blocksize %lu"
|
|
|
|
"(not supported yet)",
|
2005-04-17 06:20:36 +08:00
|
|
|
sbi->s_frag_size, sb->s_blocksize);
|
|
|
|
goto failed_mount;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sbi->s_blocks_per_group > sb->s_blocksize * 8) {
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR,
|
|
|
|
"error: #blocks per group too big: %lu",
|
2005-04-17 06:20:36 +08:00
|
|
|
sbi->s_blocks_per_group);
|
|
|
|
goto failed_mount;
|
|
|
|
}
|
|
|
|
if (sbi->s_frags_per_group > sb->s_blocksize * 8) {
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR,
|
|
|
|
"error: #fragments per group too big: %lu",
|
2005-04-17 06:20:36 +08:00
|
|
|
sbi->s_frags_per_group);
|
|
|
|
goto failed_mount;
|
|
|
|
}
|
2022-07-26 19:13:50 +08:00
|
|
|
if (sbi->s_inodes_per_group < sbi->s_inodes_per_block ||
|
|
|
|
sbi->s_inodes_per_group > sb->s_blocksize * 8) {
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR,
|
2022-07-26 19:13:50 +08:00
|
|
|
"error: invalid #inodes per group: %lu",
|
2005-04-17 06:20:36 +08:00
|
|
|
sbi->s_inodes_per_group);
|
|
|
|
goto failed_mount;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EXT2_BLOCKS_PER_GROUP(sb) == 0)
|
|
|
|
goto cantfind_ext2;
|
2019-12-18 11:19:31 +08:00
|
|
|
sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
|
|
|
|
le32_to_cpu(es->s_first_data_block) - 1)
|
|
|
|
/ EXT2_BLOCKS_PER_GROUP(sb)) + 1;
|
2022-07-26 19:13:50 +08:00
|
|
|
if ((u64)sbi->s_groups_count * sbi->s_inodes_per_group !=
|
|
|
|
le32_to_cpu(es->s_inodes_count)) {
|
|
|
|
ext2_msg(sb, KERN_ERR, "error: invalid #inodes: %u vs computed %llu",
|
|
|
|
le32_to_cpu(es->s_inodes_count),
|
|
|
|
(u64)sbi->s_groups_count * sbi->s_inodes_per_group);
|
|
|
|
goto failed_mount;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
|
|
|
|
EXT2_DESC_PER_BLOCK(sb);
|
2020-10-10 17:43:35 +08:00
|
|
|
sbi->s_group_desc = kmalloc_array(db_count,
|
treewide: kmalloc() -> kmalloc_array()
The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
patch replaces cases of:
kmalloc(a * b, gfp)
with:
kmalloc_array(a * b, gfp)
as well as handling cases of:
kmalloc(a * b * c, gfp)
with:
kmalloc(array3_size(a, b, c), gfp)
as it's slightly less ugly than:
kmalloc_array(array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
kmalloc(4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The tools/ directory was manually excluded, since it has its own
implementation of kmalloc().
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
kmalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kmalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
kmalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
- kmalloc
+ kmalloc_array
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
kmalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
kmalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
kmalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@
(
kmalloc(sizeof(THING) * C2, ...)
|
kmalloc(sizeof(TYPE) * C2, ...)
|
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(C1 * C2, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * E2
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- E1 * E2
+ E1, E2
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-13 04:55:00 +08:00
|
|
|
sizeof(struct buffer_head *),
|
|
|
|
GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (sbi->s_group_desc == NULL) {
|
2019-01-01 21:30:28 +08:00
|
|
|
ret = -ENOMEM;
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR, "error: not enough memory");
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed_mount;
|
|
|
|
}
|
2009-01-08 10:07:19 +08:00
|
|
|
bgl_lock_init(sbi->s_blockgroup_lock);
|
some kmalloc/memset ->kzalloc (tree wide)
Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc).
Here is a short excerpt of the semantic patch performing
this transformation:
@@
type T2;
expression x;
identifier f,fld;
expression E;
expression E1,E2;
expression e1,e2,e3,y;
statement S;
@@
x =
- kmalloc
+ kzalloc
(E1,E2)
... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
- memset((T2)x,0,E1);
@@
expression E1,E2,E3;
@@
- kzalloc(E1 * E2,E3)
+ kcalloc(E1,E2,E3)
[akpm@linux-foundation.org: get kcalloc args the right way around]
Signed-off-by: Yoann Padioleau <padator@wanadoo.fr>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Acked-by: Russell King <rmk@arm.linux.org.uk>
Cc: Bryan Wu <bryan.wu@analog.com>
Acked-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Dave Airlie <airlied@linux.ie>
Acked-by: Roland Dreier <rolandd@cisco.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Acked-by: Pierre Ossman <drzeus-list@drzeus.cx>
Cc: Jeff Garzik <jeff@garzik.org>
Cc: "David S. Miller" <davem@davemloft.net>
Acked-by: Greg KH <greg@kroah.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-07-19 16:49:03 +08:00
|
|
|
sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!sbi->s_debts) {
|
2019-01-01 21:30:28 +08:00
|
|
|
ret = -ENOMEM;
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR, "error: not enough memory");
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed_mount_group_desc;
|
|
|
|
}
|
|
|
|
for (i = 0; i < db_count; i++) {
|
|
|
|
block = descriptor_loc(sb, logic_sb_block, i);
|
|
|
|
sbi->s_group_desc[i] = sb_bread(sb, block);
|
|
|
|
if (!sbi->s_group_desc[i]) {
|
|
|
|
for (j = 0; j < i; j++)
|
|
|
|
brelse (sbi->s_group_desc[j]);
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR,
|
|
|
|
"error: unable to read group descriptors");
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed_mount_group_desc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!ext2_check_descriptors (sb)) {
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR, "group descriptors corrupted");
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed_mount2;
|
|
|
|
}
|
|
|
|
sbi->s_gdb_count = db_count;
|
|
|
|
get_random_bytes(&sbi->s_next_generation, sizeof(u32));
|
|
|
|
spin_lock_init(&sbi->s_next_gen_lock);
|
2006-06-23 17:05:41 +08:00
|
|
|
|
2021-03-19 08:31:31 +08:00
|
|
|
/* per filesystem reservation list head & lock */
|
2007-10-17 14:30:46 +08:00
|
|
|
spin_lock_init(&sbi->s_rsv_window_lock);
|
|
|
|
sbi->s_rsv_window_root = RB_ROOT;
|
|
|
|
/*
|
|
|
|
* Add a single, static dummy reservation to the start of the
|
|
|
|
* reservation window list --- it gives us a placeholder for
|
|
|
|
* append-at-start-of-list which makes the allocation logic
|
|
|
|
* _much_ simpler.
|
|
|
|
*/
|
|
|
|
sbi->s_rsv_window_head.rsv_start = EXT2_RESERVE_WINDOW_NOT_ALLOCATED;
|
|
|
|
sbi->s_rsv_window_head.rsv_end = EXT2_RESERVE_WINDOW_NOT_ALLOCATED;
|
|
|
|
sbi->s_rsv_window_head.rsv_alloc_hit = 0;
|
|
|
|
sbi->s_rsv_window_head.rsv_goal_size = 0;
|
|
|
|
ext2_rsv_window_add(sb, &sbi->s_rsv_window_head);
|
|
|
|
|
2007-10-17 14:25:45 +08:00
|
|
|
err = percpu_counter_init(&sbi->s_freeblocks_counter,
|
2014-09-08 08:51:29 +08:00
|
|
|
ext2_count_free_blocks(sb), GFP_KERNEL);
|
2007-10-17 14:25:45 +08:00
|
|
|
if (!err) {
|
|
|
|
err = percpu_counter_init(&sbi->s_freeinodes_counter,
|
2014-09-08 08:51:29 +08:00
|
|
|
ext2_count_free_inodes(sb), GFP_KERNEL);
|
2007-10-17 14:25:45 +08:00
|
|
|
}
|
|
|
|
if (!err) {
|
|
|
|
err = percpu_counter_init(&sbi->s_dirs_counter,
|
2014-09-08 08:51:29 +08:00
|
|
|
ext2_count_dirs(sb), GFP_KERNEL);
|
2007-10-17 14:25:45 +08:00
|
|
|
}
|
|
|
|
if (err) {
|
2019-11-29 09:36:36 +08:00
|
|
|
ret = err;
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR, "error: insufficient memory");
|
2007-10-17 14:25:45 +08:00
|
|
|
goto failed_mount3;
|
|
|
|
}
|
2016-02-23 00:56:38 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_EXT2_FS_XATTR
|
2017-06-22 23:28:55 +08:00
|
|
|
sbi->s_ea_block_cache = ext2_xattr_create_cache();
|
|
|
|
if (!sbi->s_ea_block_cache) {
|
2019-01-01 21:30:28 +08:00
|
|
|
ret = -ENOMEM;
|
2017-06-22 23:28:55 +08:00
|
|
|
ext2_msg(sb, KERN_ERR, "Failed to create ea_block_cache");
|
2016-02-23 00:56:38 +08:00
|
|
|
goto failed_mount3;
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* set up enough so that it can read an inode
|
|
|
|
*/
|
|
|
|
sb->s_op = &ext2_sops;
|
|
|
|
sb->s_export_op = &ext2_export_ops;
|
|
|
|
sb->s_xattr = ext2_xattr_handlers;
|
2010-05-19 19:16:44 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_QUOTA
|
|
|
|
sb->dq_op = &dquot_operations;
|
2017-04-06 23:02:09 +08:00
|
|
|
sb->s_qcop = &ext2_quotactl_ops;
|
2014-09-25 22:44:45 +08:00
|
|
|
sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
|
2010-05-19 19:16:44 +08:00
|
|
|
#endif
|
|
|
|
|
2008-02-07 16:15:35 +08:00
|
|
|
root = ext2_iget(sb, EXT2_ROOT_INO);
|
|
|
|
if (IS_ERR(root)) {
|
|
|
|
ret = PTR_ERR(root);
|
2006-06-23 17:05:41 +08:00
|
|
|
goto failed_mount3;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
|
2008-02-07 16:15:35 +08:00
|
|
|
iput(root);
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck");
|
2006-06-23 17:05:41 +08:00
|
|
|
goto failed_mount3;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2008-02-07 16:15:35 +08:00
|
|
|
|
2012-01-09 11:15:13 +08:00
|
|
|
sb->s_root = d_make_root(root);
|
2008-02-07 16:15:35 +08:00
|
|
|
if (!sb->s_root) {
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR, "error: get root inode failed");
|
2008-02-07 16:15:35 +08:00
|
|
|
ret = -ENOMEM;
|
|
|
|
goto failed_mount3;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL))
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_WARNING,
|
|
|
|
"warning: mounting ext3 filesystem as ext2");
|
2017-07-17 15:45:34 +08:00
|
|
|
if (ext2_setup_super (sb, es, sb_rdonly(sb)))
|
2017-11-28 05:05:09 +08:00
|
|
|
sb->s_flags |= SB_RDONLY;
|
2010-04-14 20:38:37 +08:00
|
|
|
ext2_write_super(sb);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
cantfind_ext2:
|
|
|
|
if (!silent)
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_ERR,
|
|
|
|
"error: can't find an ext2 filesystem on dev %s.",
|
|
|
|
sb->s_id);
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed_mount;
|
2006-06-23 17:05:41 +08:00
|
|
|
failed_mount3:
|
2018-11-14 07:23:53 +08:00
|
|
|
ext2_xattr_destroy_cache(sbi->s_ea_block_cache);
|
2006-06-23 17:05:41 +08:00
|
|
|
percpu_counter_destroy(&sbi->s_freeblocks_counter);
|
|
|
|
percpu_counter_destroy(&sbi->s_freeinodes_counter);
|
|
|
|
percpu_counter_destroy(&sbi->s_dirs_counter);
|
2005-04-17 06:20:36 +08:00
|
|
|
failed_mount2:
|
|
|
|
for (i = 0; i < db_count; i++)
|
|
|
|
brelse(sbi->s_group_desc[i]);
|
|
|
|
failed_mount_group_desc:
|
|
|
|
kfree(sbi->s_group_desc);
|
|
|
|
kfree(sbi->s_debts);
|
|
|
|
failed_mount:
|
|
|
|
brelse(bh);
|
|
|
|
failed_sbi:
|
dax: introduce holder for dax_device
Patch series "v14 fsdax-rmap + v11 fsdax-reflink", v2.
The patchset fsdax-rmap is aimed to support shared pages tracking for
fsdax.
It moves owner tracking from dax_assocaite_entry() to pmem device driver,
by introducing an interface ->memory_failure() for struct pagemap. This
interface is called by memory_failure() in mm, and implemented by pmem
device.
Then call holder operations to find the filesystem which the corrupted
data located in, and call filesystem handler to track files or metadata
associated with this page.
Finally we are able to try to fix the corrupted data in filesystem and do
other necessary processing, such as killing processes who are using the
files affected.
The call trace is like this:
memory_failure()
|* fsdax case
|------------
|pgmap->ops->memory_failure() => pmem_pgmap_memory_failure()
| dax_holder_notify_failure() =>
| dax_device->holder_ops->notify_failure() =>
| - xfs_dax_notify_failure()
| |* xfs_dax_notify_failure()
| |--------------------------
| | xfs_rmap_query_range()
| | xfs_dax_failure_fn()
| | * corrupted on metadata
| | try to recover data, call xfs_force_shutdown()
| | * corrupted on file data
| | try to recover data, call mf_dax_kill_procs()
|* normal case
|-------------
|mf_generic_kill_procs()
The patchset fsdax-reflink attempts to add CoW support for fsdax, and
takes XFS, which has both reflink and fsdax features, as an example.
One of the key mechanisms needed to be implemented in fsdax is CoW. Copy
the data from srcmap before we actually write data to the destination
iomap. And we just copy range in which data won't be changed.
Another mechanism is range comparison. In page cache case, readpage() is
used to load data on disk to page cache in order to be able to compare
data. In fsdax case, readpage() does not work. So, we need another
compare data with direct access support.
With the two mechanisms implemented in fsdax, we are able to make reflink
and fsdax work together in XFS.
This patch (of 14):
To easily track filesystem from a pmem device, we introduce a holder for
dax_device structure, and also its operation. This holder is used to
remember who is using this dax_device:
- When it is the backend of a filesystem, the holder will be the
instance of this filesystem.
- When this pmem device is one of the targets in a mapped device, the
holder will be this mapped device. In this case, the mapped device
has its own dax_device and it will follow the first rule. So that we
can finally track to the filesystem we needed.
The holder and holder_ops will be set when filesystem is being mounted,
or an target device is being activated.
Link: https://lkml.kernel.org/r/20220603053738.1218681-1-ruansy.fnst@fujitsu.com
Link: https://lkml.kernel.org/r/20220603053738.1218681-2-ruansy.fnst@fujitsu.com
Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dan Williams <dan.j.wiliams@intel.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Jane Chu <jane.chu@oracle.com>
Cc: Goldwyn Rodrigues <rgoldwyn@suse.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Goldwyn Rodrigues <rgoldwyn@suse.com>
Cc: Ritesh Harjani <riteshh@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2022-06-03 13:37:25 +08:00
|
|
|
fs_put_dax(sbi->s_daxdev, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
sb->s_fs_info = NULL;
|
2009-05-18 11:52:51 +08:00
|
|
|
kfree(sbi->s_blockgroup_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
kfree(sbi);
|
2008-02-07 16:15:35 +08:00
|
|
|
return ret;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2009-12-16 08:46:48 +08:00
|
|
|
static void ext2_clear_super_error(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct buffer_head *sbh = EXT2_SB(sb)->s_sbh;
|
|
|
|
|
|
|
|
if (buffer_write_io_error(sbh)) {
|
|
|
|
/*
|
|
|
|
* Oh, dear. A previous attempt to write the
|
|
|
|
* superblock failed. This could happen because the
|
|
|
|
* USB device was yanked out. Or it could happen to
|
|
|
|
* be a transient write error and maybe the block will
|
|
|
|
* be remapped. Nothing we can do but to retry the
|
|
|
|
* write and hope for the best.
|
|
|
|
*/
|
2010-04-14 20:38:33 +08:00
|
|
|
ext2_msg(sb, KERN_ERR,
|
2017-12-27 22:51:37 +08:00
|
|
|
"previous I/O error to superblock detected");
|
2009-12-16 08:46:48 +08:00
|
|
|
clear_buffer_write_io_error(sbh);
|
|
|
|
set_buffer_uptodate(sbh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-05 19:32:52 +08:00
|
|
|
void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es,
|
|
|
|
int wait)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-12-16 08:46:48 +08:00
|
|
|
ext2_clear_super_error(sb);
|
2010-04-14 20:38:38 +08:00
|
|
|
spin_lock(&EXT2_SB(sb)->s_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb));
|
|
|
|
es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb));
|
2018-06-20 22:31:40 +08:00
|
|
|
es->s_wtime = cpu_to_le32(ktime_get_real_seconds());
|
2010-04-14 20:38:38 +08:00
|
|
|
/* unlock before we do IO */
|
|
|
|
spin_unlock(&EXT2_SB(sb)->s_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
|
2010-04-14 20:38:36 +08:00
|
|
|
if (wait)
|
|
|
|
sync_dirty_buffer(EXT2_SB(sb)->s_sbh);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* In the second extended file system, it is not necessary to
|
|
|
|
* write the super block since we use a mapping of the
|
|
|
|
* disk super block in a buffer.
|
|
|
|
*
|
|
|
|
* However, this function is still used to set the fs valid
|
|
|
|
* flags to 0. We need to set this flag to 0 since the fs
|
|
|
|
* may have been checked while mounted and e2fsck may have
|
|
|
|
* set s_state to EXT2_VALID_FS after some corrections.
|
|
|
|
*/
|
2009-06-08 16:04:17 +08:00
|
|
|
static int ext2_sync_fs(struct super_block *sb, int wait)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-04-14 20:38:38 +08:00
|
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
2009-06-08 16:04:17 +08:00
|
|
|
struct ext2_super_block *es = EXT2_SB(sb)->s_es;
|
|
|
|
|
2012-07-03 22:45:29 +08:00
|
|
|
/*
|
|
|
|
* Write quota structures to quota file, sync_blockdev() will write
|
|
|
|
* them to disk later
|
|
|
|
*/
|
|
|
|
dquot_writeback_dquots(sb, -1);
|
|
|
|
|
2010-04-14 20:38:38 +08:00
|
|
|
spin_lock(&sbi->s_lock);
|
2009-06-08 16:04:17 +08:00
|
|
|
if (es->s_state & cpu_to_le16(EXT2_VALID_FS)) {
|
|
|
|
ext2_debug("setting valid to 0\n");
|
|
|
|
es->s_state &= cpu_to_le16(~EXT2_VALID_FS);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2010-04-14 20:38:38 +08:00
|
|
|
spin_unlock(&sbi->s_lock);
|
2010-04-14 20:38:36 +08:00
|
|
|
ext2_sync_super(sb, es, wait);
|
2009-06-08 16:04:17 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-12 22:20:46 +08:00
|
|
|
static int ext2_freeze(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Open but unlinked files present? Keep EXT2_VALID_FS flag cleared
|
|
|
|
* because we have unattached inodes and thus filesystem is not fully
|
|
|
|
* consistent.
|
|
|
|
*/
|
|
|
|
if (atomic_long_read(&sb->s_remove_count)) {
|
|
|
|
ext2_sync_fs(sb, 1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* Set EXT2_FS_VALID flag */
|
|
|
|
spin_lock(&sbi->s_lock);
|
|
|
|
sbi->s_es->s_state = cpu_to_le16(sbi->s_mount_state);
|
|
|
|
spin_unlock(&sbi->s_lock);
|
|
|
|
ext2_sync_super(sb, sbi->s_es, 1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ext2_unfreeze(struct super_block *sb)
|
|
|
|
{
|
|
|
|
/* Just write sb to clear EXT2_VALID_FS flag */
|
|
|
|
ext2_write_super(sb);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-06-08 16:04:17 +08:00
|
|
|
|
2017-04-05 19:32:52 +08:00
|
|
|
static void ext2_write_super(struct super_block *sb)
|
2009-06-08 16:04:17 +08:00
|
|
|
{
|
2017-07-17 15:45:34 +08:00
|
|
|
if (!sb_rdonly(sb))
|
2009-06-08 16:04:17 +08:00
|
|
|
ext2_sync_fs(sb, 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ext2_remount (struct super_block * sb, int * flags, char * data)
|
|
|
|
{
|
|
|
|
struct ext2_sb_info * sbi = EXT2_SB(sb);
|
|
|
|
struct ext2_super_block * es;
|
2017-10-09 22:34:58 +08:00
|
|
|
struct ext2_mount_options new_opts;
|
2005-07-13 04:58:29 +08:00
|
|
|
int err;
|
|
|
|
|
2014-03-13 22:14:33 +08:00
|
|
|
sync_filesystem(sb);
|
2009-05-12 21:10:54 +08:00
|
|
|
|
2017-10-09 22:46:40 +08:00
|
|
|
spin_lock(&sbi->s_lock);
|
2017-10-09 22:34:58 +08:00
|
|
|
new_opts.s_mount_opt = sbi->s_mount_opt;
|
|
|
|
new_opts.s_resuid = sbi->s_resuid;
|
|
|
|
new_opts.s_resgid = sbi->s_resgid;
|
2017-10-09 22:46:40 +08:00
|
|
|
spin_unlock(&sbi->s_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2017-10-09 22:46:40 +08:00
|
|
|
if (!parse_options(data, sb, &new_opts))
|
2017-10-09 22:34:58 +08:00
|
|
|
return -EINVAL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2017-10-09 22:46:40 +08:00
|
|
|
spin_lock(&sbi->s_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
es = sbi->s_es;
|
2017-10-09 22:34:58 +08:00
|
|
|
if ((sbi->s_mount_opt ^ new_opts.s_mount_opt) & EXT2_MOUNT_DAX) {
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_WARNING, "warning: refusing change of "
|
2015-02-17 07:59:31 +08:00
|
|
|
"dax flag with busy inodes while remounting");
|
2017-10-09 22:34:58 +08:00
|
|
|
new_opts.s_mount_opt ^= EXT2_MOUNT_DAX;
|
2009-05-12 21:10:54 +08:00
|
|
|
}
|
2017-11-28 05:05:09 +08:00
|
|
|
if ((bool)(*flags & SB_RDONLY) == sb_rdonly(sb))
|
2017-10-09 22:34:58 +08:00
|
|
|
goto out_set;
|
2017-11-28 05:05:09 +08:00
|
|
|
if (*flags & SB_RDONLY) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (le16_to_cpu(es->s_state) & EXT2_VALID_FS ||
|
2017-10-09 22:34:58 +08:00
|
|
|
!(sbi->s_mount_state & EXT2_VALID_FS))
|
|
|
|
goto out_set;
|
2010-05-19 19:16:40 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* OK, we are remounting a valid rw partition rdonly, so set
|
|
|
|
* the rdonly flag and then mark the partition as valid again.
|
|
|
|
*/
|
|
|
|
es->s_state = cpu_to_le16(sbi->s_mount_state);
|
2018-06-20 22:31:40 +08:00
|
|
|
es->s_mtime = cpu_to_le32(ktime_get_real_seconds());
|
2010-04-14 20:38:38 +08:00
|
|
|
spin_unlock(&sbi->s_lock);
|
2010-05-19 19:16:40 +08:00
|
|
|
|
2010-05-19 19:16:41 +08:00
|
|
|
err = dquot_suspend(sb, -1);
|
2017-10-09 22:34:58 +08:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
2010-05-19 19:16:40 +08:00
|
|
|
|
2010-04-14 20:38:37 +08:00
|
|
|
ext2_sync_super(sb, es, 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
__le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb,
|
|
|
|
~EXT2_FEATURE_RO_COMPAT_SUPP);
|
|
|
|
if (ret) {
|
2017-10-09 22:34:58 +08:00
|
|
|
spin_unlock(&sbi->s_lock);
|
ext2: Unify log messages in ext2
make messages produced by ext2 more unified. It should be
easy to parse.
dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2009-11-20 02:12:51 +08:00
|
|
|
ext2_msg(sb, KERN_WARNING,
|
|
|
|
"warning: couldn't remount RDWR because of "
|
|
|
|
"unsupported optional features (%x).",
|
|
|
|
le32_to_cpu(ret));
|
2017-10-09 22:34:58 +08:00
|
|
|
return -EROFS;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Mounting a RDONLY partition read-write, so reread and
|
|
|
|
* store the current valid flag. (It may have been changed
|
|
|
|
* by e2fsck since we originally mounted the partition.)
|
|
|
|
*/
|
|
|
|
sbi->s_mount_state = le16_to_cpu(es->s_state);
|
|
|
|
if (!ext2_setup_super (sb, es, 0))
|
2017-11-28 05:05:09 +08:00
|
|
|
sb->s_flags &= ~SB_RDONLY;
|
2010-04-14 20:38:38 +08:00
|
|
|
spin_unlock(&sbi->s_lock);
|
2010-05-19 19:16:40 +08:00
|
|
|
|
2010-04-14 20:38:37 +08:00
|
|
|
ext2_write_super(sb);
|
2010-05-19 19:16:40 +08:00
|
|
|
|
2010-05-19 19:16:41 +08:00
|
|
|
dquot_resume(sb, -1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2010-05-19 19:16:40 +08:00
|
|
|
|
2017-10-09 22:34:58 +08:00
|
|
|
spin_lock(&sbi->s_lock);
|
|
|
|
out_set:
|
|
|
|
sbi->s_mount_opt = new_opts.s_mount_opt;
|
|
|
|
sbi->s_resuid = new_opts.s_resuid;
|
|
|
|
sbi->s_resgid = new_opts.s_resgid;
|
2017-11-28 05:05:09 +08:00
|
|
|
sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
|
2019-05-20 13:45:03 +08:00
|
|
|
(test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0);
|
2010-04-14 20:38:38 +08:00
|
|
|
spin_unlock(&sbi->s_lock);
|
2017-10-09 22:34:58 +08:00
|
|
|
|
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-06-23 17:02:58 +08:00
|
|
|
static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-06-23 17:02:58 +08:00
|
|
|
struct super_block *sb = dentry->d_sb;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
2006-12-07 12:35:27 +08:00
|
|
|
struct ext2_super_block *es = sbi->s_es;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-04-14 20:38:38 +08:00
|
|
|
spin_lock(&sbi->s_lock);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (test_opt (sb, MINIX_DF))
|
2007-07-16 14:41:58 +08:00
|
|
|
sbi->s_overhead_last = 0;
|
|
|
|
else if (sbi->s_blocks_last != le32_to_cpu(es->s_blocks_count)) {
|
|
|
|
unsigned long i, overhead = 0;
|
|
|
|
smp_rmb();
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2007-07-16 14:41:58 +08:00
|
|
|
* Compute the overhead (FS structures). This is constant
|
|
|
|
* for a given filesystem unless the number of block groups
|
|
|
|
* changes so we cache the previous value until it does.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* All of the blocks before first_data_block are
|
|
|
|
* overhead
|
|
|
|
*/
|
2006-12-07 12:35:27 +08:00
|
|
|
overhead = le32_to_cpu(es->s_first_data_block);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add the overhead attributed to the superblock and
|
|
|
|
* block group descriptors. If the sparse superblocks
|
|
|
|
* feature is turned on, then not all groups have this.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < sbi->s_groups_count; i++)
|
|
|
|
overhead += ext2_bg_has_super(sb, i) +
|
|
|
|
ext2_bg_num_gdb(sb, i);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Every block group has an inode bitmap, a block
|
|
|
|
* bitmap, and an inode table.
|
|
|
|
*/
|
|
|
|
overhead += (sbi->s_groups_count *
|
|
|
|
(2 + sbi->s_itb_per_group));
|
2007-07-16 14:41:58 +08:00
|
|
|
sbi->s_overhead_last = overhead;
|
|
|
|
smp_wmb();
|
|
|
|
sbi->s_blocks_last = le32_to_cpu(es->s_blocks_count);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
buf->f_type = EXT2_SUPER_MAGIC;
|
|
|
|
buf->f_bsize = sb->s_blocksize;
|
2007-07-16 14:41:58 +08:00
|
|
|
buf->f_blocks = le32_to_cpu(es->s_blocks_count) - sbi->s_overhead_last;
|
2005-04-17 06:20:36 +08:00
|
|
|
buf->f_bfree = ext2_count_free_blocks(sb);
|
2007-07-16 14:41:58 +08:00
|
|
|
es->s_free_blocks_count = cpu_to_le32(buf->f_bfree);
|
2006-12-07 12:35:27 +08:00
|
|
|
buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count);
|
|
|
|
if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count))
|
2005-04-17 06:20:36 +08:00
|
|
|
buf->f_bavail = 0;
|
2006-12-07 12:35:27 +08:00
|
|
|
buf->f_files = le32_to_cpu(es->s_inodes_count);
|
|
|
|
buf->f_ffree = ext2_count_free_inodes(sb);
|
2007-07-16 14:41:58 +08:00
|
|
|
es->s_free_inodes_count = cpu_to_le32(buf->f_ffree);
|
2005-04-17 06:20:36 +08:00
|
|
|
buf->f_namelen = EXT2_NAME_LEN;
|
2021-03-23 01:39:43 +08:00
|
|
|
buf->f_fsid = uuid_to_fsid(es->s_uuid);
|
2010-04-14 20:38:38 +08:00
|
|
|
spin_unlock(&sbi->s_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-07-25 04:46:55 +08:00
|
|
|
static struct dentry *ext2_mount(struct file_system_type *fs_type,
|
|
|
|
int flags, const char *dev_name, void *data)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-07-25 04:46:55 +08:00
|
|
|
return mount_bdev(fs_type, flags, dev_name, data, ext2_fill_super);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_QUOTA
|
|
|
|
|
|
|
|
/* Read data from quotafile - avoid pagecache and such because we cannot afford
|
|
|
|
* acquiring the locks... As quota files are never truncated and quota code
|
2011-03-31 09:57:33 +08:00
|
|
|
* itself serializes the operations (and no one else should touch the files)
|
2005-04-17 06:20:36 +08:00
|
|
|
* we don't have to be afraid of races */
|
|
|
|
static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data,
|
|
|
|
size_t len, loff_t off)
|
|
|
|
{
|
|
|
|
struct inode *inode = sb_dqopt(sb)->files[type];
|
|
|
|
sector_t blk = off >> EXT2_BLOCK_SIZE_BITS(sb);
|
|
|
|
int err = 0;
|
|
|
|
int offset = off & (sb->s_blocksize - 1);
|
|
|
|
int tocopy;
|
|
|
|
size_t toread;
|
|
|
|
struct buffer_head tmp_bh;
|
|
|
|
struct buffer_head *bh;
|
|
|
|
loff_t i_size = i_size_read(inode);
|
|
|
|
|
|
|
|
if (off > i_size)
|
|
|
|
return 0;
|
|
|
|
if (off+len > i_size)
|
|
|
|
len = i_size-off;
|
|
|
|
toread = len;
|
|
|
|
while (toread > 0) {
|
2022-07-14 14:33:18 +08:00
|
|
|
tocopy = min_t(size_t, sb->s_blocksize - offset, toread);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
tmp_bh.b_state = 0;
|
2009-02-13 04:57:04 +08:00
|
|
|
tmp_bh.b_size = sb->s_blocksize;
|
2005-04-17 06:20:36 +08:00
|
|
|
err = ext2_get_block(inode, blk, &tmp_bh, 0);
|
2007-10-17 14:30:46 +08:00
|
|
|
if (err < 0)
|
2005-04-17 06:20:36 +08:00
|
|
|
return err;
|
|
|
|
if (!buffer_mapped(&tmp_bh)) /* A hole? */
|
|
|
|
memset(data, 0, tocopy);
|
|
|
|
else {
|
|
|
|
bh = sb_bread(sb, tmp_bh.b_blocknr);
|
|
|
|
if (!bh)
|
|
|
|
return -EIO;
|
|
|
|
memcpy(data, bh->b_data+offset, tocopy);
|
|
|
|
brelse(bh);
|
|
|
|
}
|
|
|
|
offset = 0;
|
|
|
|
toread -= tocopy;
|
|
|
|
data += tocopy;
|
|
|
|
blk++;
|
|
|
|
}
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write to quotafile */
|
|
|
|
static ssize_t ext2_quota_write(struct super_block *sb, int type,
|
|
|
|
const char *data, size_t len, loff_t off)
|
|
|
|
{
|
|
|
|
struct inode *inode = sb_dqopt(sb)->files[type];
|
|
|
|
sector_t blk = off >> EXT2_BLOCK_SIZE_BITS(sb);
|
|
|
|
int err = 0;
|
|
|
|
int offset = off & (sb->s_blocksize - 1);
|
|
|
|
int tocopy;
|
|
|
|
size_t towrite = len;
|
|
|
|
struct buffer_head tmp_bh;
|
|
|
|
struct buffer_head *bh;
|
|
|
|
|
|
|
|
while (towrite > 0) {
|
2022-07-14 14:33:18 +08:00
|
|
|
tocopy = min_t(size_t, sb->s_blocksize - offset, towrite);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
tmp_bh.b_state = 0;
|
2013-12-03 18:20:06 +08:00
|
|
|
tmp_bh.b_size = sb->s_blocksize;
|
2005-04-17 06:20:36 +08:00
|
|
|
err = ext2_get_block(inode, blk, &tmp_bh, 1);
|
2007-10-17 14:30:46 +08:00
|
|
|
if (err < 0)
|
2005-04-17 06:20:36 +08:00
|
|
|
goto out;
|
|
|
|
if (offset || tocopy != EXT2_BLOCK_SIZE(sb))
|
|
|
|
bh = sb_bread(sb, tmp_bh.b_blocknr);
|
|
|
|
else
|
|
|
|
bh = sb_getblk(sb, tmp_bh.b_blocknr);
|
2013-01-12 17:34:50 +08:00
|
|
|
if (unlikely(!bh)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
err = -EIO;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
lock_buffer(bh);
|
|
|
|
memcpy(bh->b_data+offset, data, tocopy);
|
|
|
|
flush_dcache_page(bh->b_page);
|
|
|
|
set_buffer_uptodate(bh);
|
|
|
|
mark_buffer_dirty(bh);
|
|
|
|
unlock_buffer(bh);
|
|
|
|
brelse(bh);
|
|
|
|
offset = 0;
|
|
|
|
towrite -= tocopy;
|
|
|
|
data += tocopy;
|
|
|
|
blk++;
|
|
|
|
}
|
|
|
|
out:
|
2012-04-26 03:29:42 +08:00
|
|
|
if (len == towrite)
|
2005-04-17 06:20:36 +08:00
|
|
|
return err;
|
|
|
|
if (inode->i_size < off+len-towrite)
|
|
|
|
i_size_write(inode, off+len-towrite);
|
2017-12-11 19:35:14 +08:00
|
|
|
inode_inc_iversion(inode);
|
2016-09-14 22:48:04 +08:00
|
|
|
inode->i_mtime = inode->i_ctime = current_time(inode);
|
2005-04-17 06:20:36 +08:00
|
|
|
mark_inode_dirty(inode);
|
|
|
|
return len - towrite;
|
|
|
|
}
|
|
|
|
|
2017-04-06 23:02:09 +08:00
|
|
|
static int ext2_quota_on(struct super_block *sb, int type, int format_id,
|
|
|
|
const struct path *path)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
struct inode *inode;
|
|
|
|
|
|
|
|
err = dquot_quota_on(sb, type, format_id, path);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
inode = d_inode(path->dentry);
|
|
|
|
inode_lock(inode);
|
|
|
|
EXT2_I(inode)->i_flags |= EXT2_NOATIME_FL | EXT2_IMMUTABLE_FL;
|
|
|
|
inode_set_flags(inode, S_NOATIME | S_IMMUTABLE,
|
|
|
|
S_NOATIME | S_IMMUTABLE);
|
|
|
|
inode_unlock(inode);
|
|
|
|
mark_inode_dirty(inode);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ext2_quota_off(struct super_block *sb, int type)
|
|
|
|
{
|
|
|
|
struct inode *inode = sb_dqopt(sb)->files[type];
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!inode || !igrab(inode))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
err = dquot_quota_off(sb, type);
|
|
|
|
if (err)
|
|
|
|
goto out_put;
|
|
|
|
|
|
|
|
inode_lock(inode);
|
|
|
|
EXT2_I(inode)->i_flags &= ~(EXT2_NOATIME_FL | EXT2_IMMUTABLE_FL);
|
|
|
|
inode_set_flags(inode, 0, S_NOATIME | S_IMMUTABLE);
|
|
|
|
inode_unlock(inode);
|
|
|
|
mark_inode_dirty(inode);
|
|
|
|
out_put:
|
|
|
|
iput(inode);
|
|
|
|
return err;
|
|
|
|
out:
|
|
|
|
return dquot_quota_off(sb, type);
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static struct file_system_type ext2_fs_type = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "ext2",
|
2010-07-25 04:46:55 +08:00
|
|
|
.mount = ext2_mount,
|
2005-04-17 06:20:36 +08:00
|
|
|
.kill_sb = kill_block_super,
|
2015-06-17 06:48:31 +08:00
|
|
|
.fs_flags = FS_REQUIRES_DEV,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
2013-03-03 11:39:14 +08:00
|
|
|
MODULE_ALIAS_FS("ext2");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static int __init init_ext2_fs(void)
|
|
|
|
{
|
2016-02-23 00:56:38 +08:00
|
|
|
int err;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
err = init_inodecache();
|
|
|
|
if (err)
|
2016-02-23 00:56:38 +08:00
|
|
|
return err;
|
2005-04-17 06:20:36 +08:00
|
|
|
err = register_filesystem(&ext2_fs_type);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
return 0;
|
|
|
|
out:
|
|
|
|
destroy_inodecache();
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit exit_ext2_fs(void)
|
|
|
|
{
|
|
|
|
unregister_filesystem(&ext2_fs_type);
|
|
|
|
destroy_inodecache();
|
|
|
|
}
|
|
|
|
|
2012-01-05 04:59:47 +08:00
|
|
|
MODULE_AUTHOR("Remy Card and others");
|
|
|
|
MODULE_DESCRIPTION("Second Extended Filesystem");
|
|
|
|
MODULE_LICENSE("GPL");
|
2005-04-17 06:20:36 +08:00
|
|
|
module_init(init_ext2_fs)
|
|
|
|
module_exit(exit_ext2_fs)
|