2018-06-06 02:42:14 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2006-06-18 22:40:27 +00:00
|
|
|
* Copyright (c) 2000-2006 Silicon Graphics, Inc.
|
2005-11-02 03:58:39 +00:00
|
|
|
* All Rights Reserved.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2009-12-14 23:14:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "xfs.h"
|
2013-10-22 23:36:05 +00:00
|
|
|
#include "xfs_shared.h"
|
2013-08-12 10:49:26 +00:00
|
|
|
#include "xfs_format.h"
|
2013-10-22 23:50:10 +00:00
|
|
|
#include "xfs_log_format.h"
|
|
|
|
#include "xfs_trans_resv.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "xfs_sb.h"
|
|
|
|
#include "xfs_mount.h"
|
|
|
|
#include "xfs_inode.h"
|
2005-11-02 03:38:42 +00:00
|
|
|
#include "xfs_btree.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "xfs_bmap.h"
|
2013-10-22 23:51:50 +00:00
|
|
|
#include "xfs_alloc.h"
|
2007-10-11 08:11:14 +00:00
|
|
|
#include "xfs_fsops.h"
|
2013-10-22 23:50:10 +00:00
|
|
|
#include "xfs_trans.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "xfs_buf_item.h"
|
2013-10-22 23:50:10 +00:00
|
|
|
#include "xfs_log.h"
|
2007-11-23 05:29:32 +00:00
|
|
|
#include "xfs_log_priv.h"
|
2013-08-12 10:49:37 +00:00
|
|
|
#include "xfs_dir2.h"
|
2008-07-18 07:11:46 +00:00
|
|
|
#include "xfs_extfree_item.h"
|
|
|
|
#include "xfs_mru_cache.h"
|
|
|
|
#include "xfs_inode_item.h"
|
2012-10-08 10:56:09 +00:00
|
|
|
#include "xfs_icache.h"
|
2009-12-14 23:14:59 +00:00
|
|
|
#include "xfs_trace.h"
|
2013-06-27 06:04:53 +00:00
|
|
|
#include "xfs_icreate_item.h"
|
2013-10-22 23:51:50 +00:00
|
|
|
#include "xfs_filestream.h"
|
|
|
|
#include "xfs_quota.h"
|
2014-09-09 01:52:42 +00:00
|
|
|
#include "xfs_sysfs.h"
|
2016-03-08 21:15:14 +00:00
|
|
|
#include "xfs_ondisk.h"
|
2016-08-03 02:04:45 +00:00
|
|
|
#include "xfs_rmap_item.h"
|
2016-10-03 16:11:20 +00:00
|
|
|
#include "xfs_refcount_item.h"
|
2016-10-03 16:11:25 +00:00
|
|
|
#include "xfs_bmap_item.h"
|
2016-10-03 16:11:38 +00:00
|
|
|
#include "xfs_reflink.h"
|
2021-01-23 00:48:44 +00:00
|
|
|
#include "xfs_pwork.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-10-18 06:20:19 +00:00
|
|
|
#include <linux/magic.h>
|
2019-11-04 21:58:46 +00:00
|
|
|
#include <linux/fs_context.h>
|
|
|
|
#include <linux/fs_parser.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-09-22 00:01:09 +00:00
|
|
|
static const struct super_operations xfs_super_operations;
|
2014-09-09 01:52:42 +00:00
|
|
|
|
2014-09-29 00:46:08 +00:00
|
|
|
static struct kset *xfs_kset; /* top-level xfs sysfs dir */
|
2014-09-09 01:52:42 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
static struct xfs_kobj xfs_dbg_kobj; /* global debug sysfs attrs */
|
|
|
|
#endif
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-05-04 16:02:42 +00:00
|
|
|
enum xfs_dax_mode {
|
|
|
|
XFS_DAX_INODE = 0,
|
|
|
|
XFS_DAX_ALWAYS = 1,
|
|
|
|
XFS_DAX_NEVER = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
xfs_mount_set_dax_mode(
|
|
|
|
struct xfs_mount *mp,
|
|
|
|
enum xfs_dax_mode mode)
|
|
|
|
{
|
|
|
|
switch (mode) {
|
|
|
|
case XFS_DAX_INODE:
|
|
|
|
mp->m_flags &= ~(XFS_MOUNT_DAX_ALWAYS | XFS_MOUNT_DAX_NEVER);
|
|
|
|
break;
|
|
|
|
case XFS_DAX_ALWAYS:
|
|
|
|
mp->m_flags |= XFS_MOUNT_DAX_ALWAYS;
|
|
|
|
mp->m_flags &= ~XFS_MOUNT_DAX_NEVER;
|
|
|
|
break;
|
|
|
|
case XFS_DAX_NEVER:
|
|
|
|
mp->m_flags |= XFS_MOUNT_DAX_NEVER;
|
|
|
|
mp->m_flags &= ~XFS_MOUNT_DAX_ALWAYS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct constant_table dax_param_enums[] = {
|
|
|
|
{"inode", XFS_DAX_INODE },
|
|
|
|
{"always", XFS_DAX_ALWAYS },
|
|
|
|
{"never", XFS_DAX_NEVER },
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2008-07-18 07:12:36 +00:00
|
|
|
/*
|
|
|
|
* Table driven mount option parser.
|
|
|
|
*/
|
|
|
|
enum {
|
2019-10-28 15:41:42 +00:00
|
|
|
Opt_logbufs, Opt_logbsize, Opt_logdev, Opt_rtdev,
|
2016-03-01 22:55:38 +00:00
|
|
|
Opt_wsync, Opt_noalign, Opt_swalloc, Opt_sunit, Opt_swidth, Opt_nouuid,
|
2019-04-28 15:32:52 +00:00
|
|
|
Opt_grpid, Opt_nogrpid, Opt_bsdgroups, Opt_sysvgroups,
|
2018-07-26 16:11:27 +00:00
|
|
|
Opt_allocsize, Opt_norecovery, Opt_inode64, Opt_inode32, Opt_ikeep,
|
|
|
|
Opt_noikeep, Opt_largeio, Opt_nolargeio, Opt_attr2, Opt_noattr2,
|
|
|
|
Opt_filestreams, Opt_quota, Opt_noquota, Opt_usrquota, Opt_grpquota,
|
|
|
|
Opt_prjquota, Opt_uquota, Opt_gquota, Opt_pquota,
|
2016-03-01 22:55:38 +00:00
|
|
|
Opt_uqnoenforce, Opt_gqnoenforce, Opt_pqnoenforce, Opt_qnoenforce,
|
2020-05-04 16:02:42 +00:00
|
|
|
Opt_discard, Opt_nodiscard, Opt_dax, Opt_dax_enum,
|
2008-07-18 07:12:36 +00:00
|
|
|
};
|
|
|
|
|
2019-09-07 11:23:15 +00:00
|
|
|
static const struct fs_parameter_spec xfs_fs_parameters[] = {
|
2019-11-04 21:58:46 +00:00
|
|
|
fsparam_u32("logbufs", Opt_logbufs),
|
|
|
|
fsparam_string("logbsize", Opt_logbsize),
|
|
|
|
fsparam_string("logdev", Opt_logdev),
|
|
|
|
fsparam_string("rtdev", Opt_rtdev),
|
|
|
|
fsparam_flag("wsync", Opt_wsync),
|
|
|
|
fsparam_flag("noalign", Opt_noalign),
|
|
|
|
fsparam_flag("swalloc", Opt_swalloc),
|
|
|
|
fsparam_u32("sunit", Opt_sunit),
|
|
|
|
fsparam_u32("swidth", Opt_swidth),
|
|
|
|
fsparam_flag("nouuid", Opt_nouuid),
|
|
|
|
fsparam_flag("grpid", Opt_grpid),
|
|
|
|
fsparam_flag("nogrpid", Opt_nogrpid),
|
|
|
|
fsparam_flag("bsdgroups", Opt_bsdgroups),
|
|
|
|
fsparam_flag("sysvgroups", Opt_sysvgroups),
|
|
|
|
fsparam_string("allocsize", Opt_allocsize),
|
|
|
|
fsparam_flag("norecovery", Opt_norecovery),
|
|
|
|
fsparam_flag("inode64", Opt_inode64),
|
|
|
|
fsparam_flag("inode32", Opt_inode32),
|
|
|
|
fsparam_flag("ikeep", Opt_ikeep),
|
|
|
|
fsparam_flag("noikeep", Opt_noikeep),
|
|
|
|
fsparam_flag("largeio", Opt_largeio),
|
|
|
|
fsparam_flag("nolargeio", Opt_nolargeio),
|
|
|
|
fsparam_flag("attr2", Opt_attr2),
|
|
|
|
fsparam_flag("noattr2", Opt_noattr2),
|
|
|
|
fsparam_flag("filestreams", Opt_filestreams),
|
|
|
|
fsparam_flag("quota", Opt_quota),
|
|
|
|
fsparam_flag("noquota", Opt_noquota),
|
|
|
|
fsparam_flag("usrquota", Opt_usrquota),
|
|
|
|
fsparam_flag("grpquota", Opt_grpquota),
|
|
|
|
fsparam_flag("prjquota", Opt_prjquota),
|
|
|
|
fsparam_flag("uquota", Opt_uquota),
|
|
|
|
fsparam_flag("gquota", Opt_gquota),
|
|
|
|
fsparam_flag("pquota", Opt_pquota),
|
|
|
|
fsparam_flag("uqnoenforce", Opt_uqnoenforce),
|
|
|
|
fsparam_flag("gqnoenforce", Opt_gqnoenforce),
|
|
|
|
fsparam_flag("pqnoenforce", Opt_pqnoenforce),
|
|
|
|
fsparam_flag("qnoenforce", Opt_qnoenforce),
|
|
|
|
fsparam_flag("discard", Opt_discard),
|
|
|
|
fsparam_flag("nodiscard", Opt_nodiscard),
|
|
|
|
fsparam_flag("dax", Opt_dax),
|
2020-05-04 16:02:42 +00:00
|
|
|
fsparam_enum("dax", Opt_dax_enum, dax_param_enums),
|
2019-11-04 21:58:46 +00:00
|
|
|
{}
|
2008-07-18 07:12:36 +00:00
|
|
|
};
|
|
|
|
|
2007-11-23 05:29:32 +00:00
|
|
|
struct proc_xfs_info {
|
2015-06-03 23:19:18 +00:00
|
|
|
uint64_t flag;
|
|
|
|
char *str;
|
2007-11-23 05:29:32 +00:00
|
|
|
};
|
|
|
|
|
2019-10-28 15:41:47 +00:00
|
|
|
static int
|
|
|
|
xfs_fs_show_options(
|
|
|
|
struct seq_file *m,
|
|
|
|
struct dentry *root)
|
2007-11-23 05:29:32 +00:00
|
|
|
{
|
|
|
|
static struct proc_xfs_info xfs_info_set[] = {
|
|
|
|
/* the few simple ones we can get from the mount struct */
|
2016-03-01 22:55:38 +00:00
|
|
|
{ XFS_MOUNT_IKEEP, ",ikeep" },
|
|
|
|
{ XFS_MOUNT_WSYNC, ",wsync" },
|
|
|
|
{ XFS_MOUNT_NOALIGN, ",noalign" },
|
|
|
|
{ XFS_MOUNT_SWALLOC, ",swalloc" },
|
|
|
|
{ XFS_MOUNT_NOUUID, ",nouuid" },
|
|
|
|
{ XFS_MOUNT_NORECOVERY, ",norecovery" },
|
|
|
|
{ XFS_MOUNT_ATTR2, ",attr2" },
|
|
|
|
{ XFS_MOUNT_FILESTREAMS, ",filestreams" },
|
|
|
|
{ XFS_MOUNT_GRPID, ",grpid" },
|
|
|
|
{ XFS_MOUNT_DISCARD, ",discard" },
|
2019-10-28 15:41:46 +00:00
|
|
|
{ XFS_MOUNT_LARGEIO, ",largeio" },
|
2020-05-04 16:02:42 +00:00
|
|
|
{ XFS_MOUNT_DAX_ALWAYS, ",dax=always" },
|
|
|
|
{ XFS_MOUNT_DAX_NEVER, ",dax=never" },
|
2007-11-23 05:29:32 +00:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
2019-10-28 15:41:47 +00:00
|
|
|
struct xfs_mount *mp = XFS_M(root->d_sb);
|
2007-11-23 05:29:32 +00:00
|
|
|
struct proc_xfs_info *xfs_infop;
|
|
|
|
|
|
|
|
for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
|
|
|
|
if (mp->m_flags & xfs_infop->flag)
|
|
|
|
seq_puts(m, xfs_infop->str);
|
|
|
|
}
|
2019-10-28 15:41:47 +00:00
|
|
|
|
|
|
|
seq_printf(m, ",inode%d",
|
|
|
|
(mp->m_flags & XFS_MOUNT_SMALL_INUMS) ? 32 : 64);
|
2007-11-23 05:29:32 +00:00
|
|
|
|
2019-10-28 15:41:45 +00:00
|
|
|
if (mp->m_flags & XFS_MOUNT_ALLOCSIZE)
|
2016-03-01 22:55:38 +00:00
|
|
|
seq_printf(m, ",allocsize=%dk",
|
2019-10-28 15:41:46 +00:00
|
|
|
(1 << mp->m_allocsize_log) >> 10);
|
2007-11-23 05:29:32 +00:00
|
|
|
|
|
|
|
if (mp->m_logbufs > 0)
|
2016-03-01 22:55:38 +00:00
|
|
|
seq_printf(m, ",logbufs=%d", mp->m_logbufs);
|
2007-11-23 05:29:32 +00:00
|
|
|
if (mp->m_logbsize > 0)
|
2016-03-01 22:55:38 +00:00
|
|
|
seq_printf(m, ",logbsize=%dk", mp->m_logbsize >> 10);
|
2007-11-23 05:29:32 +00:00
|
|
|
|
|
|
|
if (mp->m_logname)
|
2016-03-01 22:55:38 +00:00
|
|
|
seq_show_option(m, "logdev", mp->m_logname);
|
2007-11-23 05:29:32 +00:00
|
|
|
if (mp->m_rtname)
|
2016-03-01 22:55:38 +00:00
|
|
|
seq_show_option(m, "rtdev", mp->m_rtname);
|
2007-11-23 05:29:32 +00:00
|
|
|
|
|
|
|
if (mp->m_dalign > 0)
|
2016-03-01 22:55:38 +00:00
|
|
|
seq_printf(m, ",sunit=%d",
|
2007-11-23 05:29:32 +00:00
|
|
|
(int)XFS_FSB_TO_BB(mp, mp->m_dalign));
|
|
|
|
if (mp->m_swidth > 0)
|
2016-03-01 22:55:38 +00:00
|
|
|
seq_printf(m, ",swidth=%d",
|
2007-11-23 05:29:32 +00:00
|
|
|
(int)XFS_FSB_TO_BB(mp, mp->m_swidth));
|
|
|
|
|
2020-12-04 00:46:50 +00:00
|
|
|
if (mp->m_qflags & XFS_UQUOTA_ACCT) {
|
|
|
|
if (mp->m_qflags & XFS_UQUOTA_ENFD)
|
|
|
|
seq_puts(m, ",usrquota");
|
|
|
|
else
|
|
|
|
seq_puts(m, ",uqnoenforce");
|
|
|
|
}
|
2007-11-23 05:29:32 +00:00
|
|
|
|
xfs: xfs_showargs() reports group *and* project quotas enabled
If you enable group or project quotas on an XFS file system, then the
mount table presented through /proc/self/mounts erroneously shows
that both options are in effect for the file system. The root of
the problem is some bad logic in the xfs_showargs() function, which
is used to format the file system type-specific options in effect
for a file system.
The problem originated in this GIT commit:
Move platform specific mount option parse out of core XFS code
Date: 11/22/07
Author: Dave Chinner
SHA1 ID: a67d7c5f5d25d0b13a4dfb182697135b014fa478
For XFS quotas, project and group quota management are mutually
exclusive--only one can be in effect at a time. There are two
parts to managing quotas: aggregating usage information; and
enforcing limits. It is possible to have a quota in effect
(aggregating usage) but not enforced.
These features are recorded on an XFS mount point using these flags:
XFS_PQUOTA_ACCT - Project quotas are aggregated
XFS_GQUOTA_ACCT - Group quotas are aggregated
XFS_OQUOTA_ENFD - Project/group quotas are enforced
The code in error is in fs/xfs/linux-2.6/xfs_super.c:
if (mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))
seq_puts(m, "," MNTOPT_PRJQUOTA);
else if (mp->m_qflags & XFS_PQUOTA_ACCT)
seq_puts(m, "," MNTOPT_PQUOTANOENF);
if (mp->m_qflags & (XFS_GQUOTA_ACCT|XFS_OQUOTA_ENFD))
seq_puts(m, "," MNTOPT_GRPQUOTA);
else if (mp->m_qflags & XFS_GQUOTA_ACCT)
seq_puts(m, "," MNTOPT_GQUOTANOENF);
The problem is that XFS_OQUOTA_ENFD will be set in mp->m_qflags
if either group or project quotas are enforced, and as a result
both MNTOPT_PRJQUOTA and MNTOPT_GRPQUOTA will be shown as mount
options.
Signed-off-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Felix Blyakher <felixb@sgi.com>
2009-09-02 22:02:24 +00:00
|
|
|
if (mp->m_qflags & XFS_PQUOTA_ACCT) {
|
2013-06-27 22:25:10 +00:00
|
|
|
if (mp->m_qflags & XFS_PQUOTA_ENFD)
|
2016-03-01 22:55:38 +00:00
|
|
|
seq_puts(m, ",prjquota");
|
xfs: xfs_showargs() reports group *and* project quotas enabled
If you enable group or project quotas on an XFS file system, then the
mount table presented through /proc/self/mounts erroneously shows
that both options are in effect for the file system. The root of
the problem is some bad logic in the xfs_showargs() function, which
is used to format the file system type-specific options in effect
for a file system.
The problem originated in this GIT commit:
Move platform specific mount option parse out of core XFS code
Date: 11/22/07
Author: Dave Chinner
SHA1 ID: a67d7c5f5d25d0b13a4dfb182697135b014fa478
For XFS quotas, project and group quota management are mutually
exclusive--only one can be in effect at a time. There are two
parts to managing quotas: aggregating usage information; and
enforcing limits. It is possible to have a quota in effect
(aggregating usage) but not enforced.
These features are recorded on an XFS mount point using these flags:
XFS_PQUOTA_ACCT - Project quotas are aggregated
XFS_GQUOTA_ACCT - Group quotas are aggregated
XFS_OQUOTA_ENFD - Project/group quotas are enforced
The code in error is in fs/xfs/linux-2.6/xfs_super.c:
if (mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))
seq_puts(m, "," MNTOPT_PRJQUOTA);
else if (mp->m_qflags & XFS_PQUOTA_ACCT)
seq_puts(m, "," MNTOPT_PQUOTANOENF);
if (mp->m_qflags & (XFS_GQUOTA_ACCT|XFS_OQUOTA_ENFD))
seq_puts(m, "," MNTOPT_GRPQUOTA);
else if (mp->m_qflags & XFS_GQUOTA_ACCT)
seq_puts(m, "," MNTOPT_GQUOTANOENF);
The problem is that XFS_OQUOTA_ENFD will be set in mp->m_qflags
if either group or project quotas are enforced, and as a result
both MNTOPT_PRJQUOTA and MNTOPT_GRPQUOTA will be shown as mount
options.
Signed-off-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Felix Blyakher <felixb@sgi.com>
2009-09-02 22:02:24 +00:00
|
|
|
else
|
2016-03-01 22:55:38 +00:00
|
|
|
seq_puts(m, ",pqnoenforce");
|
2013-07-19 22:36:02 +00:00
|
|
|
}
|
|
|
|
if (mp->m_qflags & XFS_GQUOTA_ACCT) {
|
2013-06-27 22:25:10 +00:00
|
|
|
if (mp->m_qflags & XFS_GQUOTA_ENFD)
|
2016-03-01 22:55:38 +00:00
|
|
|
seq_puts(m, ",grpquota");
|
xfs: xfs_showargs() reports group *and* project quotas enabled
If you enable group or project quotas on an XFS file system, then the
mount table presented through /proc/self/mounts erroneously shows
that both options are in effect for the file system. The root of
the problem is some bad logic in the xfs_showargs() function, which
is used to format the file system type-specific options in effect
for a file system.
The problem originated in this GIT commit:
Move platform specific mount option parse out of core XFS code
Date: 11/22/07
Author: Dave Chinner
SHA1 ID: a67d7c5f5d25d0b13a4dfb182697135b014fa478
For XFS quotas, project and group quota management are mutually
exclusive--only one can be in effect at a time. There are two
parts to managing quotas: aggregating usage information; and
enforcing limits. It is possible to have a quota in effect
(aggregating usage) but not enforced.
These features are recorded on an XFS mount point using these flags:
XFS_PQUOTA_ACCT - Project quotas are aggregated
XFS_GQUOTA_ACCT - Group quotas are aggregated
XFS_OQUOTA_ENFD - Project/group quotas are enforced
The code in error is in fs/xfs/linux-2.6/xfs_super.c:
if (mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))
seq_puts(m, "," MNTOPT_PRJQUOTA);
else if (mp->m_qflags & XFS_PQUOTA_ACCT)
seq_puts(m, "," MNTOPT_PQUOTANOENF);
if (mp->m_qflags & (XFS_GQUOTA_ACCT|XFS_OQUOTA_ENFD))
seq_puts(m, "," MNTOPT_GRPQUOTA);
else if (mp->m_qflags & XFS_GQUOTA_ACCT)
seq_puts(m, "," MNTOPT_GQUOTANOENF);
The problem is that XFS_OQUOTA_ENFD will be set in mp->m_qflags
if either group or project quotas are enforced, and as a result
both MNTOPT_PRJQUOTA and MNTOPT_GRPQUOTA will be shown as mount
options.
Signed-off-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Felix Blyakher <felixb@sgi.com>
2009-09-02 22:02:24 +00:00
|
|
|
else
|
2016-03-01 22:55:38 +00:00
|
|
|
seq_puts(m, ",gqnoenforce");
|
xfs: xfs_showargs() reports group *and* project quotas enabled
If you enable group or project quotas on an XFS file system, then the
mount table presented through /proc/self/mounts erroneously shows
that both options are in effect for the file system. The root of
the problem is some bad logic in the xfs_showargs() function, which
is used to format the file system type-specific options in effect
for a file system.
The problem originated in this GIT commit:
Move platform specific mount option parse out of core XFS code
Date: 11/22/07
Author: Dave Chinner
SHA1 ID: a67d7c5f5d25d0b13a4dfb182697135b014fa478
For XFS quotas, project and group quota management are mutually
exclusive--only one can be in effect at a time. There are two
parts to managing quotas: aggregating usage information; and
enforcing limits. It is possible to have a quota in effect
(aggregating usage) but not enforced.
These features are recorded on an XFS mount point using these flags:
XFS_PQUOTA_ACCT - Project quotas are aggregated
XFS_GQUOTA_ACCT - Group quotas are aggregated
XFS_OQUOTA_ENFD - Project/group quotas are enforced
The code in error is in fs/xfs/linux-2.6/xfs_super.c:
if (mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))
seq_puts(m, "," MNTOPT_PRJQUOTA);
else if (mp->m_qflags & XFS_PQUOTA_ACCT)
seq_puts(m, "," MNTOPT_PQUOTANOENF);
if (mp->m_qflags & (XFS_GQUOTA_ACCT|XFS_OQUOTA_ENFD))
seq_puts(m, "," MNTOPT_GRPQUOTA);
else if (mp->m_qflags & XFS_GQUOTA_ACCT)
seq_puts(m, "," MNTOPT_GQUOTANOENF);
The problem is that XFS_OQUOTA_ENFD will be set in mp->m_qflags
if either group or project quotas are enforced, and as a result
both MNTOPT_PRJQUOTA and MNTOPT_GRPQUOTA will be shown as mount
options.
Signed-off-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Felix Blyakher <felixb@sgi.com>
2009-09-02 22:02:24 +00:00
|
|
|
}
|
2007-11-23 05:29:32 +00:00
|
|
|
|
|
|
|
if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
|
2016-03-01 22:55:38 +00:00
|
|
|
seq_puts(m, ",noquota");
|
2019-10-28 15:41:47 +00:00
|
|
|
|
|
|
|
return 0;
|
2007-11-23 05:29:32 +00:00
|
|
|
}
|
2019-05-02 03:26:30 +00:00
|
|
|
|
xfs: allow inode allocations in post-growfs disk space
Today, if we perform an xfs_growfs which adds allocation groups,
mp->m_maxagi is not properly updated when the growfs is complete.
Therefore inodes will continue to be allocated only in the
AGs which existed prior to the growfs, and the new space
won't be utilized.
This is because of this path in xfs_growfs_data_private():
xfs_growfs_data_private
xfs_initialize_perag(mp, nagcount, &nagimax);
if (mp->m_flags & XFS_MOUNT_32BITINODES)
index = xfs_set_inode32(mp);
else
index = xfs_set_inode64(mp);
if (maxagi)
*maxagi = index;
where xfs_set_inode* iterates over the (old) agcount in
mp->m_sb.sb_agblocks, which has not yet been updated
in the growfs path. So "index" will be returned based on
the old agcount, not the new one, and new AGs are not available
for inode allocation.
Fix this by explicitly passing the proper AG count (which
xfs_initialize_perag() already has) down another level,
so that xfs_set_inode* can make the proper decision about
acceptable AGs for inode allocation in the potentially
newly-added AGs.
This has been broken since 3.7, when these two
xfs_set_inode* functions were added in commit 2d2194f.
Prior to that, we looped over "agcount" not sb_agblocks
in these calculations.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-07-24 10:51:54 +00:00
|
|
|
/*
|
2016-03-01 22:58:09 +00:00
|
|
|
* Set parameters for inode allocation heuristics, taking into account
|
|
|
|
* filesystem size and inode32/inode64 mount options; i.e. specifically
|
|
|
|
* whether or not XFS_MOUNT_SMALL_INUMS is set.
|
|
|
|
*
|
|
|
|
* Inode allocation patterns are altered only if inode32 is requested
|
|
|
|
* (XFS_MOUNT_SMALL_INUMS), and the filesystem is sufficiently large.
|
|
|
|
* If altered, XFS_MOUNT_32BITINODES is set as well.
|
|
|
|
*
|
|
|
|
* An agcount independent of that in the mount structure is provided
|
|
|
|
* because in the growfs case, mp->m_sb.sb_agcount is not yet updated
|
|
|
|
* to the potentially higher ag count.
|
|
|
|
*
|
|
|
|
* Returns the maximum AG index which may contain inodes.
|
xfs: allow inode allocations in post-growfs disk space
Today, if we perform an xfs_growfs which adds allocation groups,
mp->m_maxagi is not properly updated when the growfs is complete.
Therefore inodes will continue to be allocated only in the
AGs which existed prior to the growfs, and the new space
won't be utilized.
This is because of this path in xfs_growfs_data_private():
xfs_growfs_data_private
xfs_initialize_perag(mp, nagcount, &nagimax);
if (mp->m_flags & XFS_MOUNT_32BITINODES)
index = xfs_set_inode32(mp);
else
index = xfs_set_inode64(mp);
if (maxagi)
*maxagi = index;
where xfs_set_inode* iterates over the (old) agcount in
mp->m_sb.sb_agblocks, which has not yet been updated
in the growfs path. So "index" will be returned based on
the old agcount, not the new one, and new AGs are not available
for inode allocation.
Fix this by explicitly passing the proper AG count (which
xfs_initialize_perag() already has) down another level,
so that xfs_set_inode* can make the proper decision about
acceptable AGs for inode allocation in the potentially
newly-added AGs.
This has been broken since 3.7, when these two
xfs_set_inode* functions were added in commit 2d2194f.
Prior to that, we looped over "agcount" not sb_agblocks
in these calculations.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-07-24 10:51:54 +00:00
|
|
|
*/
|
2012-09-20 13:32:38 +00:00
|
|
|
xfs_agnumber_t
|
2016-03-01 22:58:09 +00:00
|
|
|
xfs_set_inode_alloc(
|
|
|
|
struct xfs_mount *mp,
|
|
|
|
xfs_agnumber_t agcount)
|
2012-09-20 13:32:38 +00:00
|
|
|
{
|
2016-03-01 22:58:09 +00:00
|
|
|
xfs_agnumber_t index;
|
2012-09-20 13:32:40 +00:00
|
|
|
xfs_agnumber_t maxagi = 0;
|
2012-09-20 13:32:38 +00:00
|
|
|
xfs_sb_t *sbp = &mp->m_sb;
|
|
|
|
xfs_agnumber_t max_metadata;
|
2014-07-24 10:53:10 +00:00
|
|
|
xfs_agino_t agino;
|
|
|
|
xfs_ino_t ino;
|
2012-09-20 13:32:38 +00:00
|
|
|
|
2016-03-01 22:58:09 +00:00
|
|
|
/*
|
|
|
|
* Calculate how much should be reserved for inodes to meet
|
|
|
|
* the max inode percentage. Used only for inode32.
|
2012-09-20 13:32:38 +00:00
|
|
|
*/
|
2019-06-05 18:19:34 +00:00
|
|
|
if (M_IGEO(mp)->maxicount) {
|
2017-06-16 18:00:05 +00:00
|
|
|
uint64_t icount;
|
2012-09-20 13:32:38 +00:00
|
|
|
|
|
|
|
icount = sbp->sb_dblocks * sbp->sb_imax_pct;
|
|
|
|
do_div(icount, 100);
|
|
|
|
icount += sbp->sb_agblocks - 1;
|
|
|
|
do_div(icount, sbp->sb_agblocks);
|
|
|
|
max_metadata = icount;
|
|
|
|
} else {
|
xfs: allow inode allocations in post-growfs disk space
Today, if we perform an xfs_growfs which adds allocation groups,
mp->m_maxagi is not properly updated when the growfs is complete.
Therefore inodes will continue to be allocated only in the
AGs which existed prior to the growfs, and the new space
won't be utilized.
This is because of this path in xfs_growfs_data_private():
xfs_growfs_data_private
xfs_initialize_perag(mp, nagcount, &nagimax);
if (mp->m_flags & XFS_MOUNT_32BITINODES)
index = xfs_set_inode32(mp);
else
index = xfs_set_inode64(mp);
if (maxagi)
*maxagi = index;
where xfs_set_inode* iterates over the (old) agcount in
mp->m_sb.sb_agblocks, which has not yet been updated
in the growfs path. So "index" will be returned based on
the old agcount, not the new one, and new AGs are not available
for inode allocation.
Fix this by explicitly passing the proper AG count (which
xfs_initialize_perag() already has) down another level,
so that xfs_set_inode* can make the proper decision about
acceptable AGs for inode allocation in the potentially
newly-added AGs.
This has been broken since 3.7, when these two
xfs_set_inode* functions were added in commit 2d2194f.
Prior to that, we looped over "agcount" not sb_agblocks
in these calculations.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-07-24 10:51:54 +00:00
|
|
|
max_metadata = agcount;
|
2012-09-20 13:32:38 +00:00
|
|
|
}
|
|
|
|
|
2016-03-01 22:58:09 +00:00
|
|
|
/* Get the last possible inode in the filesystem */
|
2018-12-12 16:46:24 +00:00
|
|
|
agino = XFS_AGB_TO_AGINO(mp, sbp->sb_agblocks - 1);
|
2016-03-01 22:58:09 +00:00
|
|
|
ino = XFS_AGINO_TO_INO(mp, agcount - 1, agino);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If user asked for no more than 32-bit inodes, and the fs is
|
|
|
|
* sufficiently large, set XFS_MOUNT_32BITINODES if we must alter
|
|
|
|
* the allocator to accommodate the request.
|
|
|
|
*/
|
|
|
|
if ((mp->m_flags & XFS_MOUNT_SMALL_INUMS) && ino > XFS_MAXINUMBER_32)
|
|
|
|
mp->m_flags |= XFS_MOUNT_32BITINODES;
|
|
|
|
else
|
|
|
|
mp->m_flags &= ~XFS_MOUNT_32BITINODES;
|
2014-07-24 10:53:10 +00:00
|
|
|
|
xfs: allow inode allocations in post-growfs disk space
Today, if we perform an xfs_growfs which adds allocation groups,
mp->m_maxagi is not properly updated when the growfs is complete.
Therefore inodes will continue to be allocated only in the
AGs which existed prior to the growfs, and the new space
won't be utilized.
This is because of this path in xfs_growfs_data_private():
xfs_growfs_data_private
xfs_initialize_perag(mp, nagcount, &nagimax);
if (mp->m_flags & XFS_MOUNT_32BITINODES)
index = xfs_set_inode32(mp);
else
index = xfs_set_inode64(mp);
if (maxagi)
*maxagi = index;
where xfs_set_inode* iterates over the (old) agcount in
mp->m_sb.sb_agblocks, which has not yet been updated
in the growfs path. So "index" will be returned based on
the old agcount, not the new one, and new AGs are not available
for inode allocation.
Fix this by explicitly passing the proper AG count (which
xfs_initialize_perag() already has) down another level,
so that xfs_set_inode* can make the proper decision about
acceptable AGs for inode allocation in the potentially
newly-added AGs.
This has been broken since 3.7, when these two
xfs_set_inode* functions were added in commit 2d2194f.
Prior to that, we looped over "agcount" not sb_agblocks
in these calculations.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-07-24 10:51:54 +00:00
|
|
|
for (index = 0; index < agcount; index++) {
|
2016-03-01 22:58:09 +00:00
|
|
|
struct xfs_perag *pag;
|
2012-09-20 13:32:40 +00:00
|
|
|
|
2016-03-01 22:58:09 +00:00
|
|
|
ino = XFS_AGINO_TO_INO(mp, index, agino);
|
2012-09-20 13:32:38 +00:00
|
|
|
|
|
|
|
pag = xfs_perag_get(mp, index);
|
|
|
|
|
2016-03-01 22:58:09 +00:00
|
|
|
if (mp->m_flags & XFS_MOUNT_32BITINODES) {
|
|
|
|
if (ino > XFS_MAXINUMBER_32) {
|
|
|
|
pag->pagi_inodeok = 0;
|
|
|
|
pag->pagf_metadata = 0;
|
|
|
|
} else {
|
|
|
|
pag->pagi_inodeok = 1;
|
|
|
|
maxagi++;
|
|
|
|
if (index < max_metadata)
|
|
|
|
pag->pagf_metadata = 1;
|
|
|
|
else
|
|
|
|
pag->pagf_metadata = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pag->pagi_inodeok = 1;
|
|
|
|
pag->pagf_metadata = 0;
|
|
|
|
}
|
2012-09-20 13:32:38 +00:00
|
|
|
|
|
|
|
xfs_perag_put(pag);
|
|
|
|
}
|
|
|
|
|
2016-03-01 22:58:09 +00:00
|
|
|
return (mp->m_flags & XFS_MOUNT_32BITINODES) ? maxagi : agcount;
|
2012-09-20 13:32:38 +00:00
|
|
|
}
|
|
|
|
|
2009-03-04 18:34:10 +00:00
|
|
|
STATIC int
|
2005-04-16 22:20:36 +00:00
|
|
|
xfs_blkdev_get(
|
|
|
|
xfs_mount_t *mp,
|
|
|
|
const char *name,
|
|
|
|
struct block_device **bdevp)
|
|
|
|
{
|
|
|
|
int error = 0;
|
|
|
|
|
2010-11-13 10:55:18 +00:00
|
|
|
*bdevp = blkdev_get_by_path(name, FMODE_READ|FMODE_WRITE|FMODE_EXCL,
|
|
|
|
mp);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (IS_ERR(*bdevp)) {
|
|
|
|
error = PTR_ERR(*bdevp);
|
2014-12-23 22:47:27 +00:00
|
|
|
xfs_warn(mp, "Invalid device [%s], error=%d", name, error);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2014-06-25 04:58:08 +00:00
|
|
|
return error;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-03-04 18:34:10 +00:00
|
|
|
STATIC void
|
2005-04-16 22:20:36 +00:00
|
|
|
xfs_blkdev_put(
|
|
|
|
struct block_device *bdev)
|
|
|
|
{
|
|
|
|
if (bdev)
|
block: make blkdev_get/put() handle exclusive access
Over time, block layer has accumulated a set of APIs dealing with bdev
open, close, claim and release.
* blkdev_get/put() are the primary open and close functions.
* bd_claim/release() deal with exclusive open.
* open/close_bdev_exclusive() are combination of open and claim and
the other way around, respectively.
* bd_link/unlink_disk_holder() to create and remove holder/slave
symlinks.
* open_by_devnum() wraps bdget() + blkdev_get().
The interface is a bit confusing and the decoupling of open and claim
makes it impossible to properly guarantee exclusive access as
in-kernel open + claim sequence can disturb the existing exclusive
open even before the block layer knows the current open if for another
exclusive access. Reorganize the interface such that,
* blkdev_get() is extended to include exclusive access management.
@holder argument is added and, if is @FMODE_EXCL specified, it will
gain exclusive access atomically w.r.t. other exclusive accesses.
* blkdev_put() is similarly extended. It now takes @mode argument and
if @FMODE_EXCL is set, it releases an exclusive access. Also, when
the last exclusive claim is released, the holder/slave symlinks are
removed automatically.
* bd_claim/release() and close_bdev_exclusive() are no longer
necessary and either made static or removed.
* bd_link_disk_holder() remains the same but bd_unlink_disk_holder()
is no longer necessary and removed.
* open_bdev_exclusive() becomes a simple wrapper around lookup_bdev()
and blkdev_get(). It also has an unexpected extra bdev_read_only()
test which probably should be moved into blkdev_get().
* open_by_devnum() is modified to take @holder argument and pass it to
blkdev_get().
Most of bdev open/close operations are unified into blkdev_get/put()
and most exclusive accesses are tested atomically at the open time (as
it should). This cleans up code and removes some, both valid and
invalid, but unnecessary all the same, corner cases.
open_bdev_exclusive() and open_by_devnum() can use further cleanup -
rename to blkdev_get_by_path() and blkdev_get_by_devt() and drop
special features. Well, let's leave them for another day.
Most conversions are straight-forward. drbd conversion is a bit more
involved as there was some reordering, but the logic should stay the
same.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Neil Brown <neilb@suse.de>
Acked-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Acked-by: Mike Snitzer <snitzer@redhat.com>
Acked-by: Philipp Reisner <philipp.reisner@linbit.com>
Cc: Peter Osterlund <petero2@telia.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <joel.becker@oracle.com>
Cc: Alex Elder <aelder@sgi.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: dm-devel@redhat.com
Cc: drbd-dev@lists.linbit.com
Cc: Leo Chen <leochen@broadcom.com>
Cc: Scott Branden <sbranden@broadcom.com>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Cc: Joern Engel <joern@logfs.org>
Cc: reiserfs-devel@vger.kernel.org
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
2010-11-13 10:55:17 +00:00
|
|
|
blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-11-01 23:26:59 +00:00
|
|
|
void
|
|
|
|
xfs_blkdev_issue_flush(
|
|
|
|
xfs_buftarg_t *buftarg)
|
|
|
|
{
|
2021-01-26 14:52:35 +00:00
|
|
|
blkdev_issue_flush(buftarg->bt_bdev);
|
2005-11-01 23:26:59 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-05-20 01:31:13 +00:00
|
|
|
STATIC void
|
|
|
|
xfs_close_devices(
|
|
|
|
struct xfs_mount *mp)
|
|
|
|
{
|
2017-08-24 22:12:50 +00:00
|
|
|
struct dax_device *dax_ddev = mp->m_ddev_targp->bt_daxdev;
|
|
|
|
|
2008-05-20 01:31:13 +00:00
|
|
|
if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
|
2008-07-18 07:13:12 +00:00
|
|
|
struct block_device *logdev = mp->m_logdev_targp->bt_bdev;
|
2017-08-24 22:12:50 +00:00
|
|
|
struct dax_device *dax_logdev = mp->m_logdev_targp->bt_daxdev;
|
|
|
|
|
2018-04-06 17:09:42 +00:00
|
|
|
xfs_free_buftarg(mp->m_logdev_targp);
|
2008-07-18 07:13:12 +00:00
|
|
|
xfs_blkdev_put(logdev);
|
2017-08-24 22:12:50 +00:00
|
|
|
fs_put_dax(dax_logdev);
|
2008-05-20 01:31:13 +00:00
|
|
|
}
|
|
|
|
if (mp->m_rtdev_targp) {
|
2008-07-18 07:13:12 +00:00
|
|
|
struct block_device *rtdev = mp->m_rtdev_targp->bt_bdev;
|
2017-08-24 22:12:50 +00:00
|
|
|
struct dax_device *dax_rtdev = mp->m_rtdev_targp->bt_daxdev;
|
|
|
|
|
2018-04-06 17:09:42 +00:00
|
|
|
xfs_free_buftarg(mp->m_rtdev_targp);
|
2008-07-18 07:13:12 +00:00
|
|
|
xfs_blkdev_put(rtdev);
|
2017-08-24 22:12:50 +00:00
|
|
|
fs_put_dax(dax_rtdev);
|
2008-05-20 01:31:13 +00:00
|
|
|
}
|
2018-04-06 17:09:42 +00:00
|
|
|
xfs_free_buftarg(mp->m_ddev_targp);
|
2017-08-24 22:12:50 +00:00
|
|
|
fs_put_dax(dax_ddev);
|
2008-05-20 01:31:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The file system configurations are:
|
|
|
|
* (1) device (partition) with data and internal log
|
|
|
|
* (2) logical volume with data and log subvolumes.
|
|
|
|
* (3) logical volume with data, log, and realtime subvolumes.
|
|
|
|
*
|
|
|
|
* We only have to handle opening the log and realtime volumes here if
|
|
|
|
* they are present. The data subvolume has already been opened by
|
|
|
|
* get_sb_bdev() and is stored in sb->s_bdev.
|
|
|
|
*/
|
|
|
|
STATIC int
|
|
|
|
xfs_open_devices(
|
2008-10-30 06:53:24 +00:00
|
|
|
struct xfs_mount *mp)
|
2008-05-20 01:31:13 +00:00
|
|
|
{
|
|
|
|
struct block_device *ddev = mp->m_super->s_bdev;
|
2017-08-24 22:12:50 +00:00
|
|
|
struct dax_device *dax_ddev = fs_dax_get_by_bdev(ddev);
|
|
|
|
struct dax_device *dax_logdev = NULL, *dax_rtdev = NULL;
|
2008-05-20 01:31:13 +00:00
|
|
|
struct block_device *logdev = NULL, *rtdev = NULL;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Open real time and log devices - order is important.
|
|
|
|
*/
|
2008-10-30 06:53:24 +00:00
|
|
|
if (mp->m_logname) {
|
|
|
|
error = xfs_blkdev_get(mp, mp->m_logname, &logdev);
|
2008-05-20 01:31:13 +00:00
|
|
|
if (error)
|
|
|
|
goto out;
|
2017-08-24 22:12:50 +00:00
|
|
|
dax_logdev = fs_dax_get_by_bdev(logdev);
|
2008-05-20 01:31:13 +00:00
|
|
|
}
|
|
|
|
|
2008-10-30 06:53:24 +00:00
|
|
|
if (mp->m_rtname) {
|
|
|
|
error = xfs_blkdev_get(mp, mp->m_rtname, &rtdev);
|
2008-05-20 01:31:13 +00:00
|
|
|
if (error)
|
|
|
|
goto out_close_logdev;
|
|
|
|
|
|
|
|
if (rtdev == ddev || rtdev == logdev) {
|
2011-03-06 23:00:35 +00:00
|
|
|
xfs_warn(mp,
|
|
|
|
"Cannot mount filesystem with identical rtdev and ddev/logdev.");
|
2014-06-25 04:58:08 +00:00
|
|
|
error = -EINVAL;
|
2008-05-20 01:31:13 +00:00
|
|
|
goto out_close_rtdev;
|
|
|
|
}
|
2017-08-24 22:12:50 +00:00
|
|
|
dax_rtdev = fs_dax_get_by_bdev(rtdev);
|
2008-05-20 01:31:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup xfs_mount buffer target pointers
|
|
|
|
*/
|
2014-06-25 04:58:08 +00:00
|
|
|
error = -ENOMEM;
|
2017-08-24 22:12:50 +00:00
|
|
|
mp->m_ddev_targp = xfs_alloc_buftarg(mp, ddev, dax_ddev);
|
2008-05-20 01:31:13 +00:00
|
|
|
if (!mp->m_ddev_targp)
|
|
|
|
goto out_close_rtdev;
|
|
|
|
|
|
|
|
if (rtdev) {
|
2017-08-24 22:12:50 +00:00
|
|
|
mp->m_rtdev_targp = xfs_alloc_buftarg(mp, rtdev, dax_rtdev);
|
2008-05-20 01:31:13 +00:00
|
|
|
if (!mp->m_rtdev_targp)
|
|
|
|
goto out_free_ddev_targ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (logdev && logdev != ddev) {
|
2017-08-24 22:12:50 +00:00
|
|
|
mp->m_logdev_targp = xfs_alloc_buftarg(mp, logdev, dax_logdev);
|
2008-05-20 01:31:13 +00:00
|
|
|
if (!mp->m_logdev_targp)
|
|
|
|
goto out_free_rtdev_targ;
|
|
|
|
} else {
|
|
|
|
mp->m_logdev_targp = mp->m_ddev_targp;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_free_rtdev_targ:
|
|
|
|
if (mp->m_rtdev_targp)
|
2018-04-06 17:09:42 +00:00
|
|
|
xfs_free_buftarg(mp->m_rtdev_targp);
|
2008-05-20 01:31:13 +00:00
|
|
|
out_free_ddev_targ:
|
2018-04-06 17:09:42 +00:00
|
|
|
xfs_free_buftarg(mp->m_ddev_targp);
|
2008-05-20 01:31:13 +00:00
|
|
|
out_close_rtdev:
|
2014-11-30 21:24:20 +00:00
|
|
|
xfs_blkdev_put(rtdev);
|
2017-08-24 22:12:50 +00:00
|
|
|
fs_put_dax(dax_rtdev);
|
2008-05-20 01:31:13 +00:00
|
|
|
out_close_logdev:
|
2017-08-24 22:12:50 +00:00
|
|
|
if (logdev && logdev != ddev) {
|
2008-05-20 01:31:13 +00:00
|
|
|
xfs_blkdev_put(logdev);
|
2017-08-24 22:12:50 +00:00
|
|
|
fs_put_dax(dax_logdev);
|
|
|
|
}
|
2008-05-20 01:31:13 +00:00
|
|
|
out:
|
2017-08-24 22:12:50 +00:00
|
|
|
fs_put_dax(dax_ddev);
|
2008-05-20 01:31:13 +00:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2008-05-20 05:10:36 +00:00
|
|
|
/*
|
|
|
|
* Setup xfs_mount buffer target pointers based on superblock
|
|
|
|
*/
|
|
|
|
STATIC int
|
|
|
|
xfs_setup_devices(
|
|
|
|
struct xfs_mount *mp)
|
|
|
|
{
|
|
|
|
int error;
|
2008-05-20 01:31:13 +00:00
|
|
|
|
2014-04-14 09:00:29 +00:00
|
|
|
error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_sectsize);
|
2008-05-20 05:10:36 +00:00
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
|
|
|
|
unsigned int log_sector_size = BBSIZE;
|
|
|
|
|
|
|
|
if (xfs_sb_version_hassector(&mp->m_sb))
|
|
|
|
log_sector_size = mp->m_sb.sb_logsectsize;
|
|
|
|
error = xfs_setsize_buftarg(mp->m_logdev_targp,
|
|
|
|
log_sector_size);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
if (mp->m_rtdev_targp) {
|
|
|
|
error = xfs_setsize_buftarg(mp->m_rtdev_targp,
|
|
|
|
mp->m_sb.sb_sectsize);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2008-05-20 01:31:13 +00:00
|
|
|
|
2012-02-29 09:53:48 +00:00
|
|
|
STATIC int
|
|
|
|
xfs_init_mount_workqueues(
|
|
|
|
struct xfs_mount *mp)
|
|
|
|
{
|
2014-11-28 02:59:58 +00:00
|
|
|
mp->m_buf_workqueue = alloc_workqueue("xfs-buf/%s",
|
2021-01-23 00:48:42 +00:00
|
|
|
XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
|
|
|
|
1, mp->m_super->s_id);
|
2014-11-28 02:59:58 +00:00
|
|
|
if (!mp->m_buf_workqueue)
|
|
|
|
goto out;
|
|
|
|
|
2012-02-29 09:53:48 +00:00
|
|
|
mp->m_unwritten_workqueue = alloc_workqueue("xfs-conv/%s",
|
2021-01-23 00:48:42 +00:00
|
|
|
XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
|
|
|
|
0, mp->m_super->s_id);
|
2012-02-29 09:53:48 +00:00
|
|
|
if (!mp->m_unwritten_workqueue)
|
2019-04-15 20:13:21 +00:00
|
|
|
goto out_destroy_buf;
|
2012-02-29 09:53:48 +00:00
|
|
|
|
2012-04-23 07:54:32 +00:00
|
|
|
mp->m_cil_workqueue = alloc_workqueue("xfs-cil/%s",
|
2021-01-23 00:48:42 +00:00
|
|
|
XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM | WQ_UNBOUND),
|
2019-11-04 21:58:40 +00:00
|
|
|
0, mp->m_super->s_id);
|
2012-04-23 07:54:32 +00:00
|
|
|
if (!mp->m_cil_workqueue)
|
|
|
|
goto out_destroy_unwritten;
|
2012-10-08 10:56:05 +00:00
|
|
|
|
|
|
|
mp->m_reclaim_workqueue = alloc_workqueue("xfs-reclaim/%s",
|
2021-01-23 00:48:42 +00:00
|
|
|
XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
|
|
|
|
0, mp->m_super->s_id);
|
2012-10-08 10:56:05 +00:00
|
|
|
if (!mp->m_reclaim_workqueue)
|
|
|
|
goto out_destroy_cil;
|
|
|
|
|
2021-03-22 16:51:55 +00:00
|
|
|
mp->m_gc_workqueue = alloc_workqueue("xfs-gc/%s",
|
2021-01-26 00:39:01 +00:00
|
|
|
WQ_SYSFS | WQ_UNBOUND | WQ_FREEZABLE | WQ_MEM_RECLAIM,
|
2021-01-23 00:48:42 +00:00
|
|
|
0, mp->m_super->s_id);
|
2021-03-22 16:51:55 +00:00
|
|
|
if (!mp->m_gc_workqueue)
|
2019-06-29 02:27:25 +00:00
|
|
|
goto out_destroy_reclaim;
|
2012-11-06 14:50:47 +00:00
|
|
|
|
2021-01-23 00:48:42 +00:00
|
|
|
mp->m_sync_workqueue = alloc_workqueue("xfs-sync/%s",
|
|
|
|
XFS_WQFLAGS(WQ_FREEZABLE), 0, mp->m_super->s_id);
|
2017-03-28 21:51:44 +00:00
|
|
|
if (!mp->m_sync_workqueue)
|
|
|
|
goto out_destroy_eofb;
|
|
|
|
|
2012-02-29 09:53:48 +00:00
|
|
|
return 0;
|
|
|
|
|
2017-03-28 21:51:44 +00:00
|
|
|
out_destroy_eofb:
|
2021-03-22 16:51:55 +00:00
|
|
|
destroy_workqueue(mp->m_gc_workqueue);
|
2012-10-08 10:56:05 +00:00
|
|
|
out_destroy_reclaim:
|
|
|
|
destroy_workqueue(mp->m_reclaim_workqueue);
|
|
|
|
out_destroy_cil:
|
|
|
|
destroy_workqueue(mp->m_cil_workqueue);
|
2012-04-23 07:54:32 +00:00
|
|
|
out_destroy_unwritten:
|
|
|
|
destroy_workqueue(mp->m_unwritten_workqueue);
|
2014-11-28 02:59:58 +00:00
|
|
|
out_destroy_buf:
|
|
|
|
destroy_workqueue(mp->m_buf_workqueue);
|
2012-02-29 09:53:48 +00:00
|
|
|
out:
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
STATIC void
|
|
|
|
xfs_destroy_mount_workqueues(
|
|
|
|
struct xfs_mount *mp)
|
|
|
|
{
|
2017-03-28 21:51:44 +00:00
|
|
|
destroy_workqueue(mp->m_sync_workqueue);
|
2021-03-22 16:51:55 +00:00
|
|
|
destroy_workqueue(mp->m_gc_workqueue);
|
2012-10-08 10:56:05 +00:00
|
|
|
destroy_workqueue(mp->m_reclaim_workqueue);
|
2012-04-23 07:54:32 +00:00
|
|
|
destroy_workqueue(mp->m_cil_workqueue);
|
2012-02-29 09:53:48 +00:00
|
|
|
destroy_workqueue(mp->m_unwritten_workqueue);
|
2014-11-28 02:59:58 +00:00
|
|
|
destroy_workqueue(mp->m_buf_workqueue);
|
2012-02-29 09:53:48 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 20:11:10 +00:00
|
|
|
static void
|
|
|
|
xfs_flush_inodes_worker(
|
|
|
|
struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct xfs_mount *mp = container_of(work, struct xfs_mount,
|
|
|
|
m_flush_inodes_work);
|
|
|
|
struct super_block *sb = mp->m_super;
|
|
|
|
|
|
|
|
if (down_read_trylock(&sb->s_umount)) {
|
|
|
|
sync_inodes_sb(sb);
|
|
|
|
up_read(&sb->s_umount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-08 10:56:04 +00:00
|
|
|
/*
|
|
|
|
* Flush all dirty data to disk. Must not be called while holding an XFS_ILOCK
|
|
|
|
* or a page lock. We use sync_inodes_sb() here to ensure we block while waiting
|
|
|
|
* for IO to complete so that we effectively throttle multiple callers to the
|
|
|
|
* rate at which IO is completing.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
xfs_flush_inodes(
|
|
|
|
struct xfs_mount *mp)
|
|
|
|
{
|
2020-04-12 20:11:10 +00:00
|
|
|
/*
|
|
|
|
* If flush_work() returns true then that means we waited for a flush
|
|
|
|
* which was already in progress. Don't bother running another scan.
|
|
|
|
*/
|
|
|
|
if (flush_work(&mp->m_flush_inodes_work))
|
2020-03-27 15:49:44 +00:00
|
|
|
return;
|
|
|
|
|
2020-04-12 20:11:10 +00:00
|
|
|
queue_work(mp->m_sync_workqueue, &mp->m_flush_inodes_work);
|
|
|
|
flush_work(&mp->m_flush_inodes_work);
|
2012-10-08 10:56:04 +00:00
|
|
|
}
|
|
|
|
|
2008-10-30 06:36:14 +00:00
|
|
|
/* Catch misguided souls that try to use this interface on XFS */
|
2005-04-16 22:20:36 +00:00
|
|
|
STATIC struct inode *
|
2006-03-14 03:06:18 +00:00
|
|
|
xfs_fs_alloc_inode(
|
2005-04-16 22:20:36 +00:00
|
|
|
struct super_block *sb)
|
|
|
|
{
|
2008-10-30 06:36:14 +00:00
|
|
|
BUG();
|
2008-10-30 06:36:52 +00:00
|
|
|
return NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2018-10-18 06:20:11 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
static void
|
|
|
|
xfs_check_delalloc(
|
|
|
|
struct xfs_inode *ip,
|
|
|
|
int whichfork)
|
|
|
|
{
|
|
|
|
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
|
|
|
|
struct xfs_bmbt_irec got;
|
|
|
|
struct xfs_iext_cursor icur;
|
|
|
|
|
|
|
|
if (!ifp || !xfs_iext_lookup_extent(ip, ifp, 0, &icur, &got))
|
|
|
|
return;
|
|
|
|
do {
|
|
|
|
if (isnullstartblock(got.br_startblock)) {
|
|
|
|
xfs_warn(ip->i_mount,
|
|
|
|
"ino %llx %s fork has delalloc extent at [0x%llx:0x%llx]",
|
|
|
|
ip->i_ino,
|
|
|
|
whichfork == XFS_DATA_FORK ? "data" : "cow",
|
|
|
|
got.br_startoff, got.br_blockcount);
|
|
|
|
}
|
|
|
|
} while (xfs_iext_next_extent(ifp, &icur, &got));
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define xfs_check_delalloc(ip, whichfork) do { } while (0)
|
|
|
|
#endif
|
|
|
|
|
2008-10-30 06:36:14 +00:00
|
|
|
/*
|
2008-10-30 06:36:40 +00:00
|
|
|
* Now that the generic code is guaranteed not to be accessing
|
2016-05-18 03:52:42 +00:00
|
|
|
* the linux inode, we can inactivate and reclaim the inode.
|
2008-10-30 06:36:14 +00:00
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
STATIC void
|
2006-03-14 03:06:18 +00:00
|
|
|
xfs_fs_destroy_inode(
|
2009-09-29 13:48:56 +00:00
|
|
|
struct inode *inode)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-09-29 13:48:56 +00:00
|
|
|
struct xfs_inode *ip = XFS_I(inode);
|
|
|
|
|
2010-06-24 01:57:09 +00:00
|
|
|
trace_xfs_destroy_inode(ip);
|
2008-10-30 06:36:40 +00:00
|
|
|
|
2016-11-30 03:33:25 +00:00
|
|
|
ASSERT(!rwsem_is_locked(&inode->i_rwsem));
|
2016-05-18 03:52:42 +00:00
|
|
|
XFS_STATS_INC(ip->i_mount, vn_rele);
|
|
|
|
XFS_STATS_INC(ip->i_mount, vn_remove);
|
|
|
|
|
|
|
|
xfs_inactive(ip);
|
2009-09-29 13:48:56 +00:00
|
|
|
|
2018-10-18 06:20:11 +00:00
|
|
|
if (!XFS_FORCED_SHUTDOWN(ip->i_mount) && ip->i_delayed_blks) {
|
|
|
|
xfs_check_delalloc(ip, XFS_DATA_FORK);
|
|
|
|
xfs_check_delalloc(ip, XFS_COW_FORK);
|
|
|
|
ASSERT(0);
|
|
|
|
}
|
|
|
|
|
2016-05-18 03:52:42 +00:00
|
|
|
XFS_STATS_INC(ip->i_mount, vn_reclaim);
|
2009-09-29 13:48:56 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We should never get here with one of the reclaim flags already set.
|
|
|
|
*/
|
|
|
|
ASSERT_ALWAYS(!xfs_iflags_test(ip, XFS_IRECLAIMABLE));
|
|
|
|
ASSERT_ALWAYS(!xfs_iflags_test(ip, XFS_IRECLAIM));
|
|
|
|
|
|
|
|
/*
|
2020-08-17 23:41:01 +00:00
|
|
|
* We always use background reclaim here because even if the inode is
|
|
|
|
* clean, it still may be under IO and hence we have wait for IO
|
|
|
|
* completion to occur before we can reclaim the inode. The background
|
|
|
|
* reclaim path handles this more efficiently than we can here, so
|
|
|
|
* simply let background reclaim tear down all inodes.
|
2009-09-29 13:48:56 +00:00
|
|
|
*/
|
2010-01-10 23:51:47 +00:00
|
|
|
xfs_inode_set_reclaim_tag(ip);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2018-03-07 01:04:00 +00:00
|
|
|
static void
|
|
|
|
xfs_fs_dirty_inode(
|
|
|
|
struct inode *inode,
|
|
|
|
int flag)
|
|
|
|
{
|
|
|
|
struct xfs_inode *ip = XFS_I(inode);
|
|
|
|
struct xfs_mount *mp = ip->i_mount;
|
|
|
|
struct xfs_trans *tp;
|
|
|
|
|
|
|
|
if (!(inode->i_sb->s_flags & SB_LAZYTIME))
|
|
|
|
return;
|
|
|
|
if (flag != I_DIRTY_SYNC || !(inode->i_state & I_DIRTY_TIME))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp))
|
|
|
|
return;
|
|
|
|
xfs_ilock(ip, XFS_ILOCK_EXCL);
|
|
|
|
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
|
|
|
|
xfs_trans_log_inode(tp, ip, XFS_ILOG_TIMESTAMP);
|
|
|
|
xfs_trans_commit(tp);
|
|
|
|
}
|
|
|
|
|
2008-10-30 05:11:59 +00:00
|
|
|
/*
|
|
|
|
* Slab object creation initialisation for the XFS inode.
|
|
|
|
* This covers only the idempotent fields in the XFS inode;
|
|
|
|
* all other fields need to be initialised on allocation
|
tree-wide: fix comment/printk typos
"gadget", "through", "command", "maintain", "maintain", "controller", "address",
"between", "initiali[zs]e", "instead", "function", "select", "already",
"equal", "access", "management", "hierarchy", "registration", "interest",
"relative", "memory", "offset", "already",
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-11-01 19:38:34 +00:00
|
|
|
* from the slab. This avoids the need to repeatedly initialise
|
2008-10-30 05:11:59 +00:00
|
|
|
* fields in the xfs inode that left in the initialise state
|
|
|
|
* when freeing the inode.
|
|
|
|
*/
|
2008-10-30 06:36:14 +00:00
|
|
|
STATIC void
|
|
|
|
xfs_fs_inode_init_once(
|
2008-10-30 05:11:59 +00:00
|
|
|
void *inode)
|
|
|
|
{
|
|
|
|
struct xfs_inode *ip = inode;
|
|
|
|
|
|
|
|
memset(ip, 0, sizeof(struct xfs_inode));
|
2008-10-30 06:36:14 +00:00
|
|
|
|
|
|
|
/* vfs inode */
|
|
|
|
inode_init_once(VFS_I(ip));
|
|
|
|
|
|
|
|
/* xfs inode */
|
2008-10-30 05:11:59 +00:00
|
|
|
atomic_set(&ip->i_pincount, 0);
|
|
|
|
spin_lock_init(&ip->i_flags_lock);
|
|
|
|
|
2015-02-23 10:43:37 +00:00
|
|
|
mrlock_init(&ip->i_mmaplock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
|
|
|
|
"xfsino", ip->i_ino);
|
2008-10-30 05:11:59 +00:00
|
|
|
mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
|
|
|
|
"xfsino", ip->i_ino);
|
|
|
|
}
|
|
|
|
|
2012-03-22 05:15:10 +00:00
|
|
|
/*
|
|
|
|
* We do an unlocked check for XFS_IDONTCACHE here because we are already
|
|
|
|
* serialised against cache hits here via the inode->i_lock and igrab() in
|
|
|
|
* xfs_iget_cache_hit(). Hence a lookup that might clear this flag will not be
|
|
|
|
* racing with us, and it avoids needing to grab a spinlock here for every inode
|
|
|
|
* we drop the final reference on.
|
|
|
|
*/
|
|
|
|
STATIC int
|
|
|
|
xfs_fs_drop_inode(
|
|
|
|
struct inode *inode)
|
|
|
|
{
|
|
|
|
struct xfs_inode *ip = XFS_I(inode);
|
|
|
|
|
2016-10-03 16:11:29 +00:00
|
|
|
/*
|
|
|
|
* If this unlinked inode is in the middle of recovery, don't
|
|
|
|
* drop the inode just yet; log recovery will take care of
|
|
|
|
* that. See the comment for this inode flag.
|
|
|
|
*/
|
|
|
|
if (ip->i_flags & XFS_IRECOVERY) {
|
|
|
|
ASSERT(ip->i_mount->m_log->l_flags & XLOG_RECOVERY_NEEDED);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 14:41:37 +00:00
|
|
|
return generic_drop_inode(inode);
|
2012-03-22 05:15:10 +00:00
|
|
|
}
|
|
|
|
|
2019-11-04 21:58:42 +00:00
|
|
|
static void
|
|
|
|
xfs_mount_free(
|
2008-08-13 06:04:05 +00:00
|
|
|
struct xfs_mount *mp)
|
|
|
|
{
|
|
|
|
kfree(mp->m_rtname);
|
|
|
|
kfree(mp->m_logname);
|
2019-11-04 21:58:42 +00:00
|
|
|
kmem_free(mp);
|
2008-08-13 06:04:05 +00:00
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
STATIC int
|
2009-10-06 20:29:28 +00:00
|
|
|
xfs_fs_sync_fs(
|
2005-04-16 22:20:36 +00:00
|
|
|
struct super_block *sb,
|
|
|
|
int wait)
|
|
|
|
{
|
2007-08-30 07:20:39 +00:00
|
|
|
struct xfs_mount *mp = XFS_M(sb);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-10-12 01:13:35 +00:00
|
|
|
/*
|
2011-12-06 21:58:12 +00:00
|
|
|
* Doing anything during the async pass would be counterproductive.
|
2007-10-12 01:13:35 +00:00
|
|
|
*/
|
2011-12-06 21:58:12 +00:00
|
|
|
if (!wait)
|
2009-10-06 20:29:28 +00:00
|
|
|
return 0;
|
|
|
|
|
xfs: xfs_sync_fsdata is redundant
Why do we need to write the superblock to disk once we've written
all the data? We don't actually - the reasons for doing this are
lost in the mists of time, and go back to the way Irix used to drive
VFS flushing.
On linux, this code is only called from two contexts: remount and
.sync_fs. In the remount case, the call is followed by a metadata
sync, which unpins and writes the superblock. In the sync_fs case,
we only need to force the log to disk to ensure that the superblock
is correctly on disk, so we don't actually need to write it. Hence
the functionality is either redundant or superfluous and thus can be
removed.
Seeing as xfs_quiesce_data is essentially now just a log force,
remove it as well and fold the code back into the two callers.
Neither of them need the log covering check, either, as that is
redundant for the remount case, and unnecessary for the .sync_fs
case.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
2012-10-08 10:56:06 +00:00
|
|
|
xfs_log_force(mp, XFS_LOG_SYNC);
|
2009-10-06 20:29:28 +00:00
|
|
|
if (laptop_mode) {
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* The disk must be active because we're syncing.
|
2012-10-08 10:56:02 +00:00
|
|
|
* We schedule log work now (now that the disk is
|
2005-04-16 22:20:36 +00:00
|
|
|
* active) instead of later (when it might not be).
|
|
|
|
*/
|
2012-10-08 10:56:02 +00:00
|
|
|
flush_delayed_work(&mp->m_log->l_work);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-10-06 20:29:28 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
STATIC int
|
2006-03-14 03:06:18 +00:00
|
|
|
xfs_fs_statfs(
|
2006-06-23 09:02:58 +00:00
|
|
|
struct dentry *dentry,
|
2005-04-16 22:20:36 +00:00
|
|
|
struct kstatfs *statp)
|
|
|
|
{
|
2007-10-11 08:09:40 +00:00
|
|
|
struct xfs_mount *mp = XFS_M(dentry->d_sb);
|
|
|
|
xfs_sb_t *sbp = &mp->m_sb;
|
2015-03-17 22:25:59 +00:00
|
|
|
struct xfs_inode *ip = XFS_I(d_inode(dentry));
|
2017-06-16 18:00:05 +00:00
|
|
|
uint64_t fakeinos, id;
|
|
|
|
uint64_t icount;
|
|
|
|
uint64_t ifree;
|
|
|
|
uint64_t fdblocks;
|
2007-10-11 08:09:40 +00:00
|
|
|
xfs_extlen_t lsize;
|
2017-06-16 18:00:05 +00:00
|
|
|
int64_t ffree;
|
2007-10-11 08:09:40 +00:00
|
|
|
|
2018-10-18 06:20:19 +00:00
|
|
|
statp->f_type = XFS_SUPER_MAGIC;
|
2007-10-11 08:09:40 +00:00
|
|
|
statp->f_namelen = MAXNAMELEN - 1;
|
|
|
|
|
|
|
|
id = huge_encode_dev(mp->m_ddev_targp->bt_dev);
|
2020-09-18 20:45:50 +00:00
|
|
|
statp->f_fsid = u64_to_fsid(id);
|
2007-10-11 08:09:40 +00:00
|
|
|
|
2015-02-23 10:19:28 +00:00
|
|
|
icount = percpu_counter_sum(&mp->m_icount);
|
2015-02-23 10:19:53 +00:00
|
|
|
ifree = percpu_counter_sum(&mp->m_ifree);
|
2015-02-23 10:22:03 +00:00
|
|
|
fdblocks = percpu_counter_sum(&mp->m_fdblocks);
|
2007-10-11 08:09:40 +00:00
|
|
|
|
|
|
|
spin_lock(&mp->m_sb_lock);
|
|
|
|
statp->f_bsize = sbp->sb_blocksize;
|
|
|
|
lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
|
|
|
|
statp->f_blocks = sbp->sb_dblocks - lsize;
|
2015-02-23 10:22:03 +00:00
|
|
|
spin_unlock(&mp->m_sb_lock);
|
|
|
|
|
2020-05-12 18:48:35 +00:00
|
|
|
/* make sure statp->f_bfree does not underflow */
|
|
|
|
statp->f_bfree = max_t(int64_t, fdblocks - mp->m_alloc_set_aside, 0);
|
2015-02-23 10:22:03 +00:00
|
|
|
statp->f_bavail = statp->f_bfree;
|
|
|
|
|
2018-12-12 16:46:24 +00:00
|
|
|
fakeinos = XFS_FSB_TO_INO(mp, statp->f_bfree);
|
2018-06-07 14:54:02 +00:00
|
|
|
statp->f_files = min(icount + fakeinos, (uint64_t)XFS_MAXINUMBER);
|
2019-06-05 18:19:34 +00:00
|
|
|
if (M_IGEO(mp)->maxicount)
|
2009-03-29 07:51:08 +00:00
|
|
|
statp->f_files = min_t(typeof(statp->f_files),
|
|
|
|
statp->f_files,
|
2019-06-05 18:19:34 +00:00
|
|
|
M_IGEO(mp)->maxicount);
|
2010-08-24 01:46:05 +00:00
|
|
|
|
2015-02-05 22:53:02 +00:00
|
|
|
/* If sb_icount overshot maxicount, report actual allocation */
|
|
|
|
statp->f_files = max_t(typeof(statp->f_files),
|
|
|
|
statp->f_files,
|
|
|
|
sbp->sb_icount);
|
|
|
|
|
2010-08-24 01:46:05 +00:00
|
|
|
/* make sure statp->f_ffree does not underflow */
|
2015-02-23 10:19:53 +00:00
|
|
|
ffree = statp->f_files - (icount - ifree);
|
2017-06-16 18:00:05 +00:00
|
|
|
statp->f_ffree = max_t(int64_t, ffree, 0);
|
2010-08-24 01:46:05 +00:00
|
|
|
|
2007-10-11 08:09:40 +00:00
|
|
|
|
2021-03-29 18:11:44 +00:00
|
|
|
if ((ip->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
|
2013-06-27 22:25:10 +00:00
|
|
|
((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) ==
|
|
|
|
(XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))
|
2009-06-08 13:33:32 +00:00
|
|
|
xfs_qm_statvfs(ip, statp);
|
2018-01-08 18:41:33 +00:00
|
|
|
|
|
|
|
if (XFS_IS_REALTIME_MOUNT(mp) &&
|
2021-03-29 18:11:44 +00:00
|
|
|
(ip->i_diflags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) {
|
2018-01-08 18:41:33 +00:00
|
|
|
statp->f_blocks = sbp->sb_rblocks;
|
|
|
|
statp->f_bavail = statp->f_bfree =
|
|
|
|
sbp->sb_frextents * sbp->sb_rextsize;
|
|
|
|
}
|
|
|
|
|
2007-10-11 08:09:40 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2010-02-05 22:59:53 +00:00
|
|
|
STATIC void
|
|
|
|
xfs_save_resvblks(struct xfs_mount *mp)
|
|
|
|
{
|
2017-06-16 18:00:05 +00:00
|
|
|
uint64_t resblks = 0;
|
2010-02-05 22:59:53 +00:00
|
|
|
|
|
|
|
mp->m_resblks_save = mp->m_resblks;
|
|
|
|
xfs_reserve_blocks(mp, &resblks, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
STATIC void
|
|
|
|
xfs_restore_resvblks(struct xfs_mount *mp)
|
|
|
|
{
|
2017-06-16 18:00:05 +00:00
|
|
|
uint64_t resblks;
|
2010-02-05 22:59:53 +00:00
|
|
|
|
|
|
|
if (mp->m_resblks_save) {
|
|
|
|
resblks = mp->m_resblks_save;
|
|
|
|
mp->m_resblks_save = 0;
|
|
|
|
} else
|
|
|
|
resblks = xfs_default_resblks(mp);
|
|
|
|
|
|
|
|
xfs_reserve_blocks(mp, &resblks, NULL);
|
|
|
|
}
|
|
|
|
|
2019-11-04 21:58:48 +00:00
|
|
|
/*
|
|
|
|
* Second stage of a freeze. The data is already frozen so we only
|
|
|
|
* need to take care of the metadata. Once that's done sync the superblock
|
|
|
|
* to the log to dirty it in case of a crash while frozen. This ensures that we
|
|
|
|
* will recover the unlinked inode lists on the next mount.
|
|
|
|
*/
|
|
|
|
STATIC int
|
|
|
|
xfs_fs_freeze(
|
|
|
|
struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct xfs_mount *mp = XFS_M(sb);
|
xfs: Fix false positive lockdep warning with sb_internal & fs_reclaim
Depending on the workloads, the following circular locking dependency
warning between sb_internal (a percpu rwsem) and fs_reclaim (a pseudo
lock) may show up:
======================================================
WARNING: possible circular locking dependency detected
5.0.0-rc1+ #60 Tainted: G W
------------------------------------------------------
fsfreeze/4346 is trying to acquire lock:
0000000026f1d784 (fs_reclaim){+.+.}, at:
fs_reclaim_acquire.part.19+0x5/0x30
but task is already holding lock:
0000000072bfc54b (sb_internal){++++}, at: percpu_down_write+0xb4/0x650
which lock already depends on the new lock.
:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(sb_internal);
lock(fs_reclaim);
lock(sb_internal);
lock(fs_reclaim);
*** DEADLOCK ***
4 locks held by fsfreeze/4346:
#0: 00000000b478ef56 (sb_writers#8){++++}, at: percpu_down_write+0xb4/0x650
#1: 000000001ec487a9 (&type->s_umount_key#28){++++}, at: freeze_super+0xda/0x290
#2: 000000003edbd5a0 (sb_pagefaults){++++}, at: percpu_down_write+0xb4/0x650
#3: 0000000072bfc54b (sb_internal){++++}, at: percpu_down_write+0xb4/0x650
stack backtrace:
Call Trace:
dump_stack+0xe0/0x19a
print_circular_bug.isra.10.cold.34+0x2f4/0x435
check_prev_add.constprop.19+0xca1/0x15f0
validate_chain.isra.14+0x11af/0x3b50
__lock_acquire+0x728/0x1200
lock_acquire+0x269/0x5a0
fs_reclaim_acquire.part.19+0x29/0x30
fs_reclaim_acquire+0x19/0x20
kmem_cache_alloc+0x3e/0x3f0
kmem_zone_alloc+0x79/0x150
xfs_trans_alloc+0xfa/0x9d0
xfs_sync_sb+0x86/0x170
xfs_log_sbcount+0x10f/0x140
xfs_quiesce_attr+0x134/0x270
xfs_fs_freeze+0x4a/0x70
freeze_super+0x1af/0x290
do_vfs_ioctl+0xedc/0x16c0
ksys_ioctl+0x41/0x80
__x64_sys_ioctl+0x73/0xa9
do_syscall_64+0x18f/0xd23
entry_SYSCALL_64_after_hwframe+0x49/0xbe
This is a false positive as all the dirty pages are flushed out before
the filesystem can be frozen.
One way to avoid this splat is to add GFP_NOFS to the affected allocation
calls by using the memalloc_nofs_save()/memalloc_nofs_restore() pair.
This shouldn't matter unless the system is really running out of memory.
In that particular case, the filesystem freeze operation may fail while
it was succeeding previously.
Without this patch, the command sequence below will show that the lock
dependency chain sb_internal -> fs_reclaim exists.
# fsfreeze -f /home
# fsfreeze --unfreeze /home
# grep -i fs_reclaim -C 3 /proc/lockdep_chains | grep -C 5 sb_internal
After applying the patch, such sb_internal -> fs_reclaim lock dependency
chain can no longer be found. Because of that, the locking dependency
warning will not be shown.
Suggested-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Waiman Long <longman@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
2020-07-08 17:21:44 +00:00
|
|
|
unsigned int flags;
|
|
|
|
int ret;
|
2019-11-04 21:58:48 +00:00
|
|
|
|
xfs: Fix false positive lockdep warning with sb_internal & fs_reclaim
Depending on the workloads, the following circular locking dependency
warning between sb_internal (a percpu rwsem) and fs_reclaim (a pseudo
lock) may show up:
======================================================
WARNING: possible circular locking dependency detected
5.0.0-rc1+ #60 Tainted: G W
------------------------------------------------------
fsfreeze/4346 is trying to acquire lock:
0000000026f1d784 (fs_reclaim){+.+.}, at:
fs_reclaim_acquire.part.19+0x5/0x30
but task is already holding lock:
0000000072bfc54b (sb_internal){++++}, at: percpu_down_write+0xb4/0x650
which lock already depends on the new lock.
:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(sb_internal);
lock(fs_reclaim);
lock(sb_internal);
lock(fs_reclaim);
*** DEADLOCK ***
4 locks held by fsfreeze/4346:
#0: 00000000b478ef56 (sb_writers#8){++++}, at: percpu_down_write+0xb4/0x650
#1: 000000001ec487a9 (&type->s_umount_key#28){++++}, at: freeze_super+0xda/0x290
#2: 000000003edbd5a0 (sb_pagefaults){++++}, at: percpu_down_write+0xb4/0x650
#3: 0000000072bfc54b (sb_internal){++++}, at: percpu_down_write+0xb4/0x650
stack backtrace:
Call Trace:
dump_stack+0xe0/0x19a
print_circular_bug.isra.10.cold.34+0x2f4/0x435
check_prev_add.constprop.19+0xca1/0x15f0
validate_chain.isra.14+0x11af/0x3b50
__lock_acquire+0x728/0x1200
lock_acquire+0x269/0x5a0
fs_reclaim_acquire.part.19+0x29/0x30
fs_reclaim_acquire+0x19/0x20
kmem_cache_alloc+0x3e/0x3f0
kmem_zone_alloc+0x79/0x150
xfs_trans_alloc+0xfa/0x9d0
xfs_sync_sb+0x86/0x170
xfs_log_sbcount+0x10f/0x140
xfs_quiesce_attr+0x134/0x270
xfs_fs_freeze+0x4a/0x70
freeze_super+0x1af/0x290
do_vfs_ioctl+0xedc/0x16c0
ksys_ioctl+0x41/0x80
__x64_sys_ioctl+0x73/0xa9
do_syscall_64+0x18f/0xd23
entry_SYSCALL_64_after_hwframe+0x49/0xbe
This is a false positive as all the dirty pages are flushed out before
the filesystem can be frozen.
One way to avoid this splat is to add GFP_NOFS to the affected allocation
calls by using the memalloc_nofs_save()/memalloc_nofs_restore() pair.
This shouldn't matter unless the system is really running out of memory.
In that particular case, the filesystem freeze operation may fail while
it was succeeding previously.
Without this patch, the command sequence below will show that the lock
dependency chain sb_internal -> fs_reclaim exists.
# fsfreeze -f /home
# fsfreeze --unfreeze /home
# grep -i fs_reclaim -C 3 /proc/lockdep_chains | grep -C 5 sb_internal
After applying the patch, such sb_internal -> fs_reclaim lock dependency
chain can no longer be found. Because of that, the locking dependency
warning will not be shown.
Suggested-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Waiman Long <longman@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
2020-07-08 17:21:44 +00:00
|
|
|
/*
|
|
|
|
* The filesystem is now frozen far enough that memory reclaim
|
|
|
|
* cannot safely operate on the filesystem. Hence we need to
|
|
|
|
* set a GFP_NOFS context here to avoid recursion deadlocks.
|
|
|
|
*/
|
|
|
|
flags = memalloc_nofs_save();
|
2021-01-23 00:48:44 +00:00
|
|
|
xfs_blockgc_stop(mp);
|
2019-11-04 21:58:48 +00:00
|
|
|
xfs_save_resvblks(mp);
|
2021-01-23 00:48:24 +00:00
|
|
|
ret = xfs_log_quiesce(mp);
|
xfs: Fix false positive lockdep warning with sb_internal & fs_reclaim
Depending on the workloads, the following circular locking dependency
warning between sb_internal (a percpu rwsem) and fs_reclaim (a pseudo
lock) may show up:
======================================================
WARNING: possible circular locking dependency detected
5.0.0-rc1+ #60 Tainted: G W
------------------------------------------------------
fsfreeze/4346 is trying to acquire lock:
0000000026f1d784 (fs_reclaim){+.+.}, at:
fs_reclaim_acquire.part.19+0x5/0x30
but task is already holding lock:
0000000072bfc54b (sb_internal){++++}, at: percpu_down_write+0xb4/0x650
which lock already depends on the new lock.
:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(sb_internal);
lock(fs_reclaim);
lock(sb_internal);
lock(fs_reclaim);
*** DEADLOCK ***
4 locks held by fsfreeze/4346:
#0: 00000000b478ef56 (sb_writers#8){++++}, at: percpu_down_write+0xb4/0x650
#1: 000000001ec487a9 (&type->s_umount_key#28){++++}, at: freeze_super+0xda/0x290
#2: 000000003edbd5a0 (sb_pagefaults){++++}, at: percpu_down_write+0xb4/0x650
#3: 0000000072bfc54b (sb_internal){++++}, at: percpu_down_write+0xb4/0x650
stack backtrace:
Call Trace:
dump_stack+0xe0/0x19a
print_circular_bug.isra.10.cold.34+0x2f4/0x435
check_prev_add.constprop.19+0xca1/0x15f0
validate_chain.isra.14+0x11af/0x3b50
__lock_acquire+0x728/0x1200
lock_acquire+0x269/0x5a0
fs_reclaim_acquire.part.19+0x29/0x30
fs_reclaim_acquire+0x19/0x20
kmem_cache_alloc+0x3e/0x3f0
kmem_zone_alloc+0x79/0x150
xfs_trans_alloc+0xfa/0x9d0
xfs_sync_sb+0x86/0x170
xfs_log_sbcount+0x10f/0x140
xfs_quiesce_attr+0x134/0x270
xfs_fs_freeze+0x4a/0x70
freeze_super+0x1af/0x290
do_vfs_ioctl+0xedc/0x16c0
ksys_ioctl+0x41/0x80
__x64_sys_ioctl+0x73/0xa9
do_syscall_64+0x18f/0xd23
entry_SYSCALL_64_after_hwframe+0x49/0xbe
This is a false positive as all the dirty pages are flushed out before
the filesystem can be frozen.
One way to avoid this splat is to add GFP_NOFS to the affected allocation
calls by using the memalloc_nofs_save()/memalloc_nofs_restore() pair.
This shouldn't matter unless the system is really running out of memory.
In that particular case, the filesystem freeze operation may fail while
it was succeeding previously.
Without this patch, the command sequence below will show that the lock
dependency chain sb_internal -> fs_reclaim exists.
# fsfreeze -f /home
# fsfreeze --unfreeze /home
# grep -i fs_reclaim -C 3 /proc/lockdep_chains | grep -C 5 sb_internal
After applying the patch, such sb_internal -> fs_reclaim lock dependency
chain can no longer be found. Because of that, the locking dependency
warning will not be shown.
Suggested-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Waiman Long <longman@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
2020-07-08 17:21:44 +00:00
|
|
|
memalloc_nofs_restore(flags);
|
|
|
|
return ret;
|
2019-11-04 21:58:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
STATIC int
|
|
|
|
xfs_fs_unfreeze(
|
|
|
|
struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct xfs_mount *mp = XFS_M(sb);
|
|
|
|
|
|
|
|
xfs_restore_resvblks(mp);
|
|
|
|
xfs_log_work_queue(mp);
|
2021-01-23 00:48:44 +00:00
|
|
|
xfs_blockgc_start(mp);
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function fills in xfs_mount_t fields based on mount args.
|
|
|
|
* Note: the superblock _has_ now been read in.
|
|
|
|
*/
|
|
|
|
STATIC int
|
|
|
|
xfs_finish_flags(
|
|
|
|
struct xfs_mount *mp)
|
|
|
|
{
|
|
|
|
int ronly = (mp->m_flags & XFS_MOUNT_RDONLY);
|
|
|
|
|
|
|
|
/* Fail a mount where the logbuf is smaller than the log stripe */
|
|
|
|
if (xfs_sb_version_haslogv2(&mp->m_sb)) {
|
|
|
|
if (mp->m_logbsize <= 0 &&
|
|
|
|
mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE) {
|
|
|
|
mp->m_logbsize = mp->m_sb.sb_logsunit;
|
|
|
|
} else if (mp->m_logbsize > 0 &&
|
|
|
|
mp->m_logbsize < mp->m_sb.sb_logsunit) {
|
|
|
|
xfs_warn(mp,
|
|
|
|
"logbuf size must be greater than or equal to log stripe size");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Fail a mount if the logbuf is larger than 32K */
|
|
|
|
if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) {
|
|
|
|
xfs_warn(mp,
|
|
|
|
"logbuf size for version 1 logs must be 16K or 32K");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* V5 filesystems always use attr2 format for attributes.
|
|
|
|
*/
|
|
|
|
if (xfs_sb_version_hascrc(&mp->m_sb) &&
|
|
|
|
(mp->m_flags & XFS_MOUNT_NOATTR2)) {
|
|
|
|
xfs_warn(mp, "Cannot mount a V5 filesystem as noattr2. "
|
|
|
|
"attr2 is always enabled for V5 filesystems.");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* mkfs'ed attr2 will turn on attr2 mount unless explicitly
|
|
|
|
* told by noattr2 to turn it off
|
|
|
|
*/
|
|
|
|
if (xfs_sb_version_hasattr2(&mp->m_sb) &&
|
|
|
|
!(mp->m_flags & XFS_MOUNT_NOATTR2))
|
|
|
|
mp->m_flags |= XFS_MOUNT_ATTR2;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prohibit r/w mounts of read-only filesystems
|
|
|
|
*/
|
|
|
|
if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) {
|
|
|
|
xfs_warn(mp,
|
|
|
|
"cannot mount a read-only filesystem as read-write");
|
|
|
|
return -EROFS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) &&
|
|
|
|
(mp->m_qflags & (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE)) &&
|
|
|
|
!xfs_sb_version_has_pquotino(&mp->m_sb)) {
|
|
|
|
xfs_warn(mp,
|
|
|
|
"Super block does not support project and group quota together");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
xfs_init_percpu_counters(
|
|
|
|
struct xfs_mount *mp)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = percpu_counter_init(&mp->m_icount, 0, GFP_KERNEL);
|
|
|
|
if (error)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
error = percpu_counter_init(&mp->m_ifree, 0, GFP_KERNEL);
|
|
|
|
if (error)
|
|
|
|
goto free_icount;
|
|
|
|
|
|
|
|
error = percpu_counter_init(&mp->m_fdblocks, 0, GFP_KERNEL);
|
|
|
|
if (error)
|
|
|
|
goto free_ifree;
|
|
|
|
|
|
|
|
error = percpu_counter_init(&mp->m_delalloc_blks, 0, GFP_KERNEL);
|
|
|
|
if (error)
|
|
|
|
goto free_fdblocks;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
free_fdblocks:
|
|
|
|
percpu_counter_destroy(&mp->m_fdblocks);
|
|
|
|
free_ifree:
|
|
|
|
percpu_counter_destroy(&mp->m_ifree);
|
|
|
|
free_icount:
|
|
|
|
percpu_counter_destroy(&mp->m_icount);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
xfs_reinit_percpu_counters(
|
|
|
|
struct xfs_mount *mp)
|
|
|
|
{
|
|
|
|
percpu_counter_set(&mp->m_icount, mp->m_sb.sb_icount);
|
|
|
|
percpu_counter_set(&mp->m_ifree, mp->m_sb.sb_ifree);
|
|
|
|
percpu_counter_set(&mp->m_fdblocks, mp->m_sb.sb_fdblocks);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xfs_destroy_percpu_counters(
|
|
|
|
struct xfs_mount *mp)
|
|
|
|
{
|
|
|
|
percpu_counter_destroy(&mp->m_icount);
|
|
|
|
percpu_counter_destroy(&mp->m_ifree);
|
|
|
|
percpu_counter_destroy(&mp->m_fdblocks);
|
|
|
|
ASSERT(XFS_FORCED_SHUTDOWN(mp) ||
|
|
|
|
percpu_counter_sum(&mp->m_delalloc_blks) == 0);
|
|
|
|
percpu_counter_destroy(&mp->m_delalloc_blks);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xfs_fs_put_super(
|
|
|
|
struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct xfs_mount *mp = XFS_M(sb);
|
|
|
|
|
|
|
|
/* if ->fill_super failed, we have no mount to tear down */
|
|
|
|
if (!sb->s_fs_info)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xfs_notice(mp, "Unmounting Filesystem");
|
|
|
|
xfs_filestream_unmount(mp);
|
|
|
|
xfs_unmountfs(mp);
|
|
|
|
|
|
|
|
xfs_freesb(mp);
|
|
|
|
free_percpu(mp->m_stats.xs_stats);
|
|
|
|
xfs_destroy_percpu_counters(mp);
|
|
|
|
xfs_destroy_mount_workqueues(mp);
|
|
|
|
xfs_close_devices(mp);
|
|
|
|
|
|
|
|
sb->s_fs_info = NULL;
|
|
|
|
xfs_mount_free(mp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static long
|
|
|
|
xfs_fs_nr_cached_objects(
|
|
|
|
struct super_block *sb,
|
|
|
|
struct shrink_control *sc)
|
|
|
|
{
|
|
|
|
/* Paranoia: catch incorrect calls during mount setup or teardown */
|
|
|
|
if (WARN_ON_ONCE(!sb->s_fs_info))
|
|
|
|
return 0;
|
|
|
|
return xfs_reclaim_inodes_count(XFS_M(sb));
|
|
|
|
}
|
|
|
|
|
|
|
|
static long
|
|
|
|
xfs_fs_free_cached_objects(
|
|
|
|
struct super_block *sb,
|
|
|
|
struct shrink_control *sc)
|
2012-10-08 10:56:07 +00:00
|
|
|
{
|
2019-11-04 21:58:48 +00:00
|
|
|
return xfs_reclaim_inodes_nr(XFS_M(sb), sc->nr_to_scan);
|
|
|
|
}
|
2012-10-08 10:56:07 +00:00
|
|
|
|
2019-11-04 21:58:48 +00:00
|
|
|
static const struct super_operations xfs_super_operations = {
|
|
|
|
.alloc_inode = xfs_fs_alloc_inode,
|
|
|
|
.destroy_inode = xfs_fs_destroy_inode,
|
|
|
|
.dirty_inode = xfs_fs_dirty_inode,
|
|
|
|
.drop_inode = xfs_fs_drop_inode,
|
|
|
|
.put_super = xfs_fs_put_super,
|
|
|
|
.sync_fs = xfs_fs_sync_fs,
|
|
|
|
.freeze_fs = xfs_fs_freeze,
|
|
|
|
.unfreeze_fs = xfs_fs_unfreeze,
|
|
|
|
.statfs = xfs_fs_statfs,
|
|
|
|
.show_options = xfs_fs_show_options,
|
|
|
|
.nr_cached_objects = xfs_fs_nr_cached_objects,
|
|
|
|
.free_cached_objects = xfs_fs_free_cached_objects,
|
|
|
|
};
|
2012-10-08 10:56:07 +00:00
|
|
|
|
2019-11-04 21:58:48 +00:00
|
|
|
static int
|
|
|
|
suffix_kstrtoint(
|
|
|
|
const char *s,
|
|
|
|
unsigned int base,
|
|
|
|
int *res)
|
|
|
|
{
|
|
|
|
int last, shift_left_factor = 0, _res;
|
|
|
|
char *value;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
value = kstrdup(s, GFP_KERNEL);
|
|
|
|
if (!value)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
last = strlen(value) - 1;
|
|
|
|
if (value[last] == 'K' || value[last] == 'k') {
|
|
|
|
shift_left_factor = 10;
|
|
|
|
value[last] = '\0';
|
|
|
|
}
|
|
|
|
if (value[last] == 'M' || value[last] == 'm') {
|
|
|
|
shift_left_factor = 20;
|
|
|
|
value[last] = '\0';
|
|
|
|
}
|
|
|
|
if (value[last] == 'G' || value[last] == 'g') {
|
|
|
|
shift_left_factor = 30;
|
|
|
|
value[last] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (kstrtoint(value, base, &_res))
|
|
|
|
ret = -EINVAL;
|
|
|
|
kfree(value);
|
|
|
|
*res = _res << shift_left_factor;
|
|
|
|
return ret;
|
2012-10-08 10:56:07 +00:00
|
|
|
}
|
|
|
|
|
2021-03-22 16:52:02 +00:00
|
|
|
static inline void
|
|
|
|
xfs_fs_warn_deprecated(
|
|
|
|
struct fs_context *fc,
|
|
|
|
struct fs_parameter *param,
|
|
|
|
uint64_t flag,
|
|
|
|
bool value)
|
|
|
|
{
|
|
|
|
/* Don't print the warning if reconfiguring and current mount point
|
|
|
|
* already had the flag set
|
|
|
|
*/
|
|
|
|
if ((fc->purpose & FS_CONTEXT_FOR_RECONFIGURE) &&
|
|
|
|
!!(XFS_M(fc->root->d_sb)->m_flags & flag) == value)
|
|
|
|
return;
|
|
|
|
xfs_warn(fc->s_fs_info, "%s mount option is deprecated.", param->key);
|
|
|
|
}
|
|
|
|
|
2007-10-11 08:11:14 +00:00
|
|
|
/*
|
2019-11-04 21:58:48 +00:00
|
|
|
* Set mount state from a mount option.
|
|
|
|
*
|
|
|
|
* NOTE: mp->m_super is NULL here!
|
2007-10-11 08:11:14 +00:00
|
|
|
*/
|
2019-11-04 21:58:48 +00:00
|
|
|
static int
|
2020-12-04 23:59:39 +00:00
|
|
|
xfs_fs_parse_param(
|
2019-11-04 21:58:48 +00:00
|
|
|
struct fs_context *fc,
|
|
|
|
struct fs_parameter *param)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2021-03-22 16:52:01 +00:00
|
|
|
struct xfs_mount *parsing_mp = fc->s_fs_info;
|
2019-11-04 21:58:48 +00:00
|
|
|
struct fs_parse_result result;
|
|
|
|
int size = 0;
|
|
|
|
int opt;
|
2007-10-11 08:11:14 +00:00
|
|
|
|
2019-09-07 11:23:15 +00:00
|
|
|
opt = fs_parse(fc, xfs_fs_parameters, param, &result);
|
2019-11-04 21:58:48 +00:00
|
|
|
if (opt < 0)
|
|
|
|
return opt;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2019-11-04 21:58:48 +00:00
|
|
|
switch (opt) {
|
|
|
|
case Opt_logbufs:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_logbufs = result.uint_32;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_logbsize:
|
2021-03-22 16:52:01 +00:00
|
|
|
if (suffix_kstrtoint(param->string, 10, &parsing_mp->m_logbsize))
|
2019-11-04 21:58:48 +00:00
|
|
|
return -EINVAL;
|
|
|
|
return 0;
|
|
|
|
case Opt_logdev:
|
2021-03-22 16:52:01 +00:00
|
|
|
kfree(parsing_mp->m_logname);
|
|
|
|
parsing_mp->m_logname = kstrdup(param->string, GFP_KERNEL);
|
|
|
|
if (!parsing_mp->m_logname)
|
2019-11-04 21:58:48 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
return 0;
|
|
|
|
case Opt_rtdev:
|
2021-03-22 16:52:01 +00:00
|
|
|
kfree(parsing_mp->m_rtname);
|
|
|
|
parsing_mp->m_rtname = kstrdup(param->string, GFP_KERNEL);
|
|
|
|
if (!parsing_mp->m_rtname)
|
2019-11-04 21:58:48 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
return 0;
|
|
|
|
case Opt_allocsize:
|
|
|
|
if (suffix_kstrtoint(param->string, 10, &size))
|
|
|
|
return -EINVAL;
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_allocsize_log = ffs(size) - 1;
|
|
|
|
parsing_mp->m_flags |= XFS_MOUNT_ALLOCSIZE;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_grpid:
|
|
|
|
case Opt_bsdgroups:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags |= XFS_MOUNT_GRPID;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_nogrpid:
|
|
|
|
case Opt_sysvgroups:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags &= ~XFS_MOUNT_GRPID;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_wsync:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags |= XFS_MOUNT_WSYNC;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_norecovery:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags |= XFS_MOUNT_NORECOVERY;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_noalign:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags |= XFS_MOUNT_NOALIGN;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_swalloc:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags |= XFS_MOUNT_SWALLOC;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_sunit:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_dalign = result.uint_32;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_swidth:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_swidth = result.uint_32;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_inode32:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_inode64:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_nouuid:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags |= XFS_MOUNT_NOUUID;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_largeio:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags |= XFS_MOUNT_LARGEIO;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_nolargeio:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags &= ~XFS_MOUNT_LARGEIO;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_filestreams:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags |= XFS_MOUNT_FILESTREAMS;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_noquota:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
|
|
|
|
parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
|
|
|
|
parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_quota:
|
|
|
|
case Opt_uquota:
|
|
|
|
case Opt_usrquota:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
|
2019-11-04 21:58:48 +00:00
|
|
|
XFS_UQUOTA_ENFD);
|
|
|
|
return 0;
|
|
|
|
case Opt_qnoenforce:
|
|
|
|
case Opt_uqnoenforce:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
|
|
|
|
parsing_mp->m_qflags &= ~XFS_UQUOTA_ENFD;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_pquota:
|
|
|
|
case Opt_prjquota:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
|
2019-11-04 21:58:48 +00:00
|
|
|
XFS_PQUOTA_ENFD);
|
|
|
|
return 0;
|
|
|
|
case Opt_pqnoenforce:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
|
|
|
|
parsing_mp->m_qflags &= ~XFS_PQUOTA_ENFD;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_gquota:
|
|
|
|
case Opt_grpquota:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
|
2019-11-04 21:58:48 +00:00
|
|
|
XFS_GQUOTA_ENFD);
|
|
|
|
return 0;
|
|
|
|
case Opt_gqnoenforce:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
|
|
|
|
parsing_mp->m_qflags &= ~XFS_GQUOTA_ENFD;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_discard:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags |= XFS_MOUNT_DISCARD;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_nodiscard:
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags &= ~XFS_MOUNT_DISCARD;
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
#ifdef CONFIG_FS_DAX
|
|
|
|
case Opt_dax:
|
2021-03-22 16:52:01 +00:00
|
|
|
xfs_mount_set_dax_mode(parsing_mp, XFS_DAX_ALWAYS);
|
2020-05-04 16:02:42 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_dax_enum:
|
2021-03-22 16:52:01 +00:00
|
|
|
xfs_mount_set_dax_mode(parsing_mp, result.uint_32);
|
2019-11-04 21:58:48 +00:00
|
|
|
return 0;
|
|
|
|
#endif
|
2020-09-25 18:10:29 +00:00
|
|
|
/* Following mount options will be removed in September 2025 */
|
|
|
|
case Opt_ikeep:
|
2021-03-22 16:52:02 +00:00
|
|
|
xfs_fs_warn_deprecated(fc, param, XFS_MOUNT_IKEEP, true);
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags |= XFS_MOUNT_IKEEP;
|
2020-09-25 18:10:29 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_noikeep:
|
2021-03-22 16:52:02 +00:00
|
|
|
xfs_fs_warn_deprecated(fc, param, XFS_MOUNT_IKEEP, false);
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags &= ~XFS_MOUNT_IKEEP;
|
2020-09-25 18:10:29 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_attr2:
|
2021-03-22 16:52:02 +00:00
|
|
|
xfs_fs_warn_deprecated(fc, param, XFS_MOUNT_ATTR2, true);
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags |= XFS_MOUNT_ATTR2;
|
2020-09-25 18:10:29 +00:00
|
|
|
return 0;
|
|
|
|
case Opt_noattr2:
|
2021-03-22 16:52:02 +00:00
|
|
|
xfs_fs_warn_deprecated(fc, param, XFS_MOUNT_NOATTR2, true);
|
2021-03-22 16:52:01 +00:00
|
|
|
parsing_mp->m_flags &= ~XFS_MOUNT_ATTR2;
|
|
|
|
parsing_mp->m_flags |= XFS_MOUNT_NOATTR2;
|
2020-09-25 18:10:29 +00:00
|
|
|
return 0;
|
2019-11-04 21:58:48 +00:00
|
|
|
default:
|
2021-03-22 16:52:01 +00:00
|
|
|
xfs_warn(parsing_mp, "unknown mount option [%s].", param->key);
|
2019-11-04 21:58:48 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2010-02-05 22:59:53 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-11-04 21:58:48 +00:00
|
|
|
static int
|
2020-12-04 23:59:39 +00:00
|
|
|
xfs_fs_validate_params(
|
2008-05-20 01:30:59 +00:00
|
|
|
struct xfs_mount *mp)
|
|
|
|
{
|
2013-06-05 02:09:09 +00:00
|
|
|
/*
|
2019-11-04 21:58:48 +00:00
|
|
|
* no recovery flag requires a read-only mount
|
2013-06-05 02:09:09 +00:00
|
|
|
*/
|
2019-11-04 21:58:48 +00:00
|
|
|
if ((mp->m_flags & XFS_MOUNT_NORECOVERY) &&
|
|
|
|
!(mp->m_flags & XFS_MOUNT_RDONLY)) {
|
|
|
|
xfs_warn(mp, "no-recovery mounts must be read-only.");
|
2014-06-25 04:58:08 +00:00
|
|
|
return -EINVAL;
|
2013-06-05 02:09:09 +00:00
|
|
|
}
|
|
|
|
|
2019-11-04 21:58:48 +00:00
|
|
|
if ((mp->m_flags & XFS_MOUNT_NOALIGN) &&
|
|
|
|
(mp->m_dalign || mp->m_swidth)) {
|
2011-03-06 23:00:35 +00:00
|
|
|
xfs_warn(mp,
|
2019-11-04 21:58:48 +00:00
|
|
|
"sunit and swidth options incompatible with the noalign option");
|
|
|
|
return -EINVAL;
|
2008-05-20 01:30:59 +00:00
|
|
|
}
|
|
|
|
|
2019-11-04 21:58:48 +00:00
|
|
|
if (!IS_ENABLED(CONFIG_XFS_QUOTA) && mp->m_qflags != 0) {
|
|
|
|
xfs_warn(mp, "quota support not available in this kernel.");
|
2014-06-25 04:58:08 +00:00
|
|
|
return -EINVAL;
|
2013-07-19 22:36:02 +00:00
|
|
|
}
|
|
|
|
|
2019-11-04 21:58:48 +00:00
|
|
|
if ((mp->m_dalign && !mp->m_swidth) ||
|
|
|
|
(!mp->m_dalign && mp->m_swidth)) {
|
|
|
|
xfs_warn(mp, "sunit and swidth must be specified together");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2015-02-23 10:22:31 +00:00
|
|
|
|
2019-11-04 21:58:48 +00:00
|
|
|
if (mp->m_dalign && (mp->m_swidth % mp->m_dalign != 0)) {
|
|
|
|
xfs_warn(mp,
|
|
|
|
"stripe width (%d) must be a multiple of the stripe unit (%d)",
|
|
|
|
mp->m_swidth, mp->m_dalign);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2015-02-23 10:22:31 +00:00
|
|
|
|
2019-11-04 21:58:48 +00:00
|
|
|
if (mp->m_logbufs != -1 &&
|
|
|
|
mp->m_logbufs != 0 &&
|
|
|
|
(mp->m_logbufs < XLOG_MIN_ICLOGS ||
|
|
|
|
mp->m_logbufs > XLOG_MAX_ICLOGS)) {
|
|
|
|
xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]",
|
|
|
|
mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2015-02-23 10:22:31 +00:00
|
|
|
|
2019-11-04 21:58:48 +00:00
|
|
|
if (mp->m_logbsize != -1 &&
|
|
|
|
mp->m_logbsize != 0 &&
|
|
|
|
(mp->m_logbsize < XLOG_MIN_RECORD_BSIZE ||
|
|
|
|
mp->m_logbsize > XLOG_MAX_RECORD_BSIZE ||
|
|
|
|
!is_power_of_2(mp->m_logbsize))) {
|
|
|
|
xfs_warn(mp,
|
|
|
|
"invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
|
|
|
|
mp->m_logbsize);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2015-02-23 10:22:31 +00:00
|
|
|
|
2019-11-04 21:58:48 +00:00
|
|
|
if ((mp->m_flags & XFS_MOUNT_ALLOCSIZE) &&
|
|
|
|
(mp->m_allocsize_log > XFS_MAX_IO_LOG ||
|
|
|
|
mp->m_allocsize_log < XFS_MIN_IO_LOG)) {
|
|
|
|
xfs_warn(mp, "invalid log iosize: %d [not %d-%d]",
|
|
|
|
mp->m_allocsize_log, XFS_MIN_IO_LOG, XFS_MAX_IO_LOG);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2019-04-26 01:26:22 +00:00
|
|
|
|
2015-02-23 10:22:31 +00:00
|
|
|
return 0;
|
2018-03-24 00:54:32 +00:00
|
|
|
}
|
2007-08-30 07:21:22 +00:00
|
|
|
|
2019-11-04 21:58:46 +00:00
|
|
|
static int
|
2020-12-04 23:59:39 +00:00
|
|
|
xfs_fs_fill_super(
|
2018-03-24 00:54:32 +00:00
|
|
|
struct super_block *sb,
|
2019-11-04 21:58:46 +00:00
|
|
|
struct fs_context *fc)
|
2018-03-24 00:54:32 +00:00
|
|
|
{
|
2019-11-04 21:58:46 +00:00
|
|
|
struct xfs_mount *mp = sb->s_fs_info;
|
2018-03-24 00:54:32 +00:00
|
|
|
struct inode *root;
|
2019-11-06 16:07:46 +00:00
|
|
|
int flags = 0, error;
|
2018-03-24 00:54:32 +00:00
|
|
|
|
2019-11-04 21:58:46 +00:00
|
|
|
mp->m_super = sb;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-12-04 23:59:39 +00:00
|
|
|
error = xfs_fs_validate_params(mp);
|
2007-08-30 07:20:39 +00:00
|
|
|
if (error)
|
2019-11-04 21:58:40 +00:00
|
|
|
goto out_free_names;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
sb_min_blocksize(sb, BBSIZE);
|
2008-06-23 03:23:01 +00:00
|
|
|
sb->s_xattr = xfs_xattr_handlers;
|
2006-03-14 03:06:18 +00:00
|
|
|
sb->s_export_op = &xfs_export_operations;
|
2009-02-09 07:47:34 +00:00
|
|
|
#ifdef CONFIG_XFS_QUOTA
|
2006-03-14 03:06:18 +00:00
|
|
|
sb->s_qcop = &xfs_quotactl_operations;
|
2014-09-30 20:35:33 +00:00
|
|
|
sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ;
|
2009-02-09 07:47:34 +00:00
|
|
|
#endif
|
2006-03-14 03:06:18 +00:00
|
|
|
sb->s_op = &xfs_super_operations;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-11 04:50:23 +00:00
|
|
|
/*
|
|
|
|
* Delay mount work if the debug hook is set. This is debug
|
|
|
|
* instrumention to coordinate simulation of xfs mount failures with
|
|
|
|
* VFS superblock operations
|
|
|
|
*/
|
|
|
|
if (xfs_globals.mount_delay) {
|
|
|
|
xfs_notice(mp, "Delaying mount for %d seconds.",
|
|
|
|
xfs_globals.mount_delay);
|
|
|
|
msleep(xfs_globals.mount_delay * 1000);
|
|
|
|
}
|
|
|
|
|
2019-11-04 21:58:46 +00:00
|
|
|
if (fc->sb_flags & SB_SILENT)
|
2008-05-20 01:30:59 +00:00
|
|
|
flags |= XFS_MFSI_QUIET;
|
|
|
|
|
2008-10-30 06:53:24 +00:00
|
|
|
error = xfs_open_devices(mp);
|
2008-05-20 01:31:13 +00:00
|
|
|
if (error)
|
2019-11-04 21:58:40 +00:00
|
|
|
goto out_free_names;
|
2008-05-20 01:30:59 +00:00
|
|
|
|
2014-06-25 04:58:08 +00:00
|
|
|
error = xfs_init_mount_workqueues(mp);
|
2010-09-30 02:25:54 +00:00
|
|
|
if (error)
|
|
|
|
goto out_close_devices;
|
2008-05-20 05:10:52 +00:00
|
|
|
|
2015-02-23 10:22:31 +00:00
|
|
|
error = xfs_init_percpu_counters(mp);
|
2012-02-29 09:53:48 +00:00
|
|
|
if (error)
|
|
|
|
goto out_destroy_workqueues;
|
|
|
|
|
2015-10-12 07:21:19 +00:00
|
|
|
/* Allocate stats memory before we do operations that might use it */
|
|
|
|
mp->m_stats.xs_stats = alloc_percpu(struct xfsstats);
|
|
|
|
if (!mp->m_stats.xs_stats) {
|
2015-10-18 21:42:47 +00:00
|
|
|
error = -ENOMEM;
|
2015-10-12 07:21:19 +00:00
|
|
|
goto out_destroy_counters;
|
|
|
|
}
|
|
|
|
|
2008-05-20 01:30:59 +00:00
|
|
|
error = xfs_readsb(mp, flags);
|
|
|
|
if (error)
|
2015-10-12 07:21:19 +00:00
|
|
|
goto out_free_stats;
|
2008-10-30 06:53:24 +00:00
|
|
|
|
|
|
|
error = xfs_finish_flags(mp);
|
2008-05-20 01:30:59 +00:00
|
|
|
if (error)
|
2008-05-20 05:11:05 +00:00
|
|
|
goto out_free_sb;
|
2008-05-20 01:30:59 +00:00
|
|
|
|
2008-05-20 05:10:36 +00:00
|
|
|
error = xfs_setup_devices(mp);
|
2008-05-20 01:31:13 +00:00
|
|
|
if (error)
|
2008-05-20 05:11:05 +00:00
|
|
|
goto out_free_sb;
|
2008-05-20 01:30:59 +00:00
|
|
|
|
2020-09-10 17:57:17 +00:00
|
|
|
/* V4 support is undergoing deprecation. */
|
|
|
|
if (!xfs_sb_version_hascrc(&mp->m_sb)) {
|
|
|
|
#ifdef CONFIG_XFS_SUPPORT_V4
|
|
|
|
xfs_warn_once(mp,
|
|
|
|
"Deprecated V4 format (crc=0) will not be supported after September 2030.");
|
|
|
|
#else
|
|
|
|
xfs_warn(mp,
|
|
|
|
"Deprecated V4 format (crc=0) not supported by kernel.");
|
|
|
|
error = -EINVAL;
|
|
|
|
goto out_free_sb;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-11-24 19:45:55 +00:00
|
|
|
/* Filesystem claims it needs repair, so refuse the mount. */
|
|
|
|
if (xfs_sb_version_needsrepair(&mp->m_sb)) {
|
|
|
|
xfs_warn(mp, "Filesystem needs repair. Please run xfs_repair.");
|
|
|
|
error = -EFSCORRUPTED;
|
|
|
|
goto out_free_sb;
|
|
|
|
}
|
|
|
|
|
2020-11-24 19:45:54 +00:00
|
|
|
/*
|
|
|
|
* Don't touch the filesystem if a user tool thinks it owns the primary
|
|
|
|
* superblock. mkfs doesn't clear the flag from secondary supers, so
|
|
|
|
* we don't check them at all.
|
|
|
|
*/
|
|
|
|
if (mp->m_sb.sb_inprogress) {
|
|
|
|
xfs_warn(mp, "Offline file system operation in progress!");
|
|
|
|
error = -EFSCORRUPTED;
|
|
|
|
goto out_free_sb;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Until this is fixed only page-sized or smaller data blocks work.
|
|
|
|
*/
|
|
|
|
if (mp->m_sb.sb_blocksize > PAGE_SIZE) {
|
|
|
|
xfs_warn(mp,
|
|
|
|
"File system with blocksize %d bytes. "
|
|
|
|
"Only pagesize (%ld) or less will currently work.",
|
|
|
|
mp->m_sb.sb_blocksize, PAGE_SIZE);
|
|
|
|
error = -ENOSYS;
|
|
|
|
goto out_free_sb;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ensure this filesystem fits in the page cache limits */
|
|
|
|
if (xfs_sb_validate_fsb_count(&mp->m_sb, mp->m_sb.sb_dblocks) ||
|
|
|
|
xfs_sb_validate_fsb_count(&mp->m_sb, mp->m_sb.sb_rblocks)) {
|
|
|
|
xfs_warn(mp,
|
|
|
|
"file system too large to be mounted on this system.");
|
|
|
|
error = -EFBIG;
|
|
|
|
goto out_free_sb;
|
|
|
|
}
|
|
|
|
|
2020-01-02 21:20:13 +00:00
|
|
|
/*
|
|
|
|
* XFS block mappings use 54 bits to store the logical block offset.
|
|
|
|
* This should suffice to handle the maximum file size that the VFS
|
|
|
|
* supports (currently 2^63 bytes on 64-bit and ULONG_MAX << PAGE_SHIFT
|
|
|
|
* bytes on 32-bit), but as XFS and VFS have gotten the s_maxbytes
|
|
|
|
* calculation wrong on 32-bit kernels in the past, we'll add a WARN_ON
|
|
|
|
* to check this assertion.
|
|
|
|
*
|
|
|
|
* Avoid integer overflow by comparing the maximum bmbt offset to the
|
|
|
|
* maximum pagecache offset in units of fs blocks.
|
|
|
|
*/
|
2020-12-04 21:28:35 +00:00
|
|
|
if (!xfs_verify_fileoff(mp, XFS_B_TO_FSBT(mp, MAX_LFS_FILESIZE))) {
|
2020-01-02 21:20:13 +00:00
|
|
|
xfs_warn(mp,
|
|
|
|
"MAX_LFS_FILESIZE block offset (%llu) exceeds extent map maximum (%llu)!",
|
|
|
|
XFS_B_TO_FSBT(mp, MAX_LFS_FILESIZE),
|
|
|
|
XFS_MAX_FILEOFF);
|
|
|
|
error = -EINVAL;
|
|
|
|
goto out_free_sb;
|
|
|
|
}
|
|
|
|
|
2008-05-20 01:30:59 +00:00
|
|
|
error = xfs_filestream_mount(mp);
|
|
|
|
if (error)
|
2008-05-20 05:11:05 +00:00
|
|
|
goto out_free_sb;
|
2008-05-20 01:30:59 +00:00
|
|
|
|
2011-03-25 22:14:57 +00:00
|
|
|
/*
|
|
|
|
* we must configure the block size in the superblock before we run the
|
|
|
|
* full mount process as the mount process can lookup and cache inodes.
|
|
|
|
*/
|
2018-10-18 06:20:19 +00:00
|
|
|
sb->s_magic = XFS_SUPER_MAGIC;
|
2007-10-11 08:09:40 +00:00
|
|
|
sb->s_blocksize = mp->m_sb.sb_blocksize;
|
|
|
|
sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
|
2020-01-02 21:20:13 +00:00
|
|
|
sb->s_maxbytes = MAX_LFS_FILESIZE;
|
2012-02-06 17:45:27 +00:00
|
|
|
sb->s_max_links = XFS_MAXLINK;
|
2005-04-16 22:20:36 +00:00
|
|
|
sb->s_time_gran = 1;
|
2020-08-17 16:59:07 +00:00
|
|
|
if (xfs_sb_version_hasbigtime(&mp->m_sb)) {
|
|
|
|
sb->s_time_min = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MIN);
|
|
|
|
sb->s_time_max = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MAX);
|
|
|
|
} else {
|
|
|
|
sb->s_time_min = XFS_LEGACY_TIME_MIN;
|
|
|
|
sb->s_time_max = XFS_LEGACY_TIME_MAX;
|
|
|
|
}
|
2020-08-24 18:58:01 +00:00
|
|
|
trace_xfs_inode_timestamp_range(mp, sb->s_time_min, sb->s_time_max);
|
2019-06-29 02:30:22 +00:00
|
|
|
sb->s_iflags |= SB_I_CGROUPWB;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
set_posix_acl_flag(sb);
|
|
|
|
|
2013-06-27 06:04:59 +00:00
|
|
|
/* version 5 superblocks support inode version counters. */
|
|
|
|
if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_5)
|
2017-10-18 20:56:26 +00:00
|
|
|
sb->s_flags |= SB_I_VERSION;
|
2013-06-27 06:04:59 +00:00
|
|
|
|
2020-08-17 16:59:07 +00:00
|
|
|
if (xfs_sb_version_hasbigtime(&mp->m_sb))
|
|
|
|
xfs_warn(mp,
|
|
|
|
"EXPERIMENTAL big timestamp feature in use. Use at your own risk!");
|
|
|
|
|
2020-05-04 16:02:41 +00:00
|
|
|
if (mp->m_flags & XFS_MOUNT_DAX_ALWAYS) {
|
2018-05-30 20:03:46 +00:00
|
|
|
bool rtdev_is_dax = false, datadev_is_dax;
|
2018-05-30 20:03:45 +00:00
|
|
|
|
2015-06-03 23:19:18 +00:00
|
|
|
xfs_warn(mp,
|
2016-05-10 16:23:56 +00:00
|
|
|
"DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
|
|
|
|
|
2018-05-30 20:03:46 +00:00
|
|
|
datadev_is_dax = bdev_dax_supported(mp->m_ddev_targp->bt_bdev,
|
|
|
|
sb->s_blocksize);
|
2018-05-30 20:03:45 +00:00
|
|
|
if (mp->m_rtdev_targp)
|
2018-05-30 20:03:46 +00:00
|
|
|
rtdev_is_dax = bdev_dax_supported(
|
|
|
|
mp->m_rtdev_targp->bt_bdev, sb->s_blocksize);
|
|
|
|
if (!rtdev_is_dax && !datadev_is_dax) {
|
2015-06-03 23:19:18 +00:00
|
|
|
xfs_alert(mp,
|
2016-05-10 16:23:56 +00:00
|
|
|
"DAX unsupported by block device. Turning off DAX.");
|
2020-05-04 16:02:42 +00:00
|
|
|
xfs_mount_set_dax_mode(mp, XFS_DAX_NEVER);
|
2015-06-03 23:19:18 +00:00
|
|
|
}
|
2018-01-31 22:21:56 +00:00
|
|
|
if (xfs_sb_version_hasreflink(&mp->m_sb)) {
|
2016-10-03 16:11:52 +00:00
|
|
|
xfs_alert(mp,
|
2018-01-08 21:30:08 +00:00
|
|
|
"DAX and reflink cannot be used together!");
|
2018-01-31 22:21:56 +00:00
|
|
|
error = -EINVAL;
|
|
|
|
goto out_filestream_unmount;
|
|
|
|
}
|
2015-06-03 23:19:18 +00:00
|
|
|
}
|
|
|
|
|
2017-09-18 19:03:56 +00:00
|
|
|
if (mp->m_flags & XFS_MOUNT_DISCARD) {
|
|
|
|
struct request_queue *q = bdev_get_queue(sb->s_bdev);
|
|
|
|
|
|
|
|
if (!blk_queue_discard(q)) {
|
|
|
|
xfs_warn(mp, "mounting with \"discard\" option, but "
|
|
|
|
"the device does not support discard");
|
|
|
|
mp->m_flags &= ~XFS_MOUNT_DISCARD;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-18 17:38:49 +00:00
|
|
|
if (xfs_sb_version_hasreflink(&mp->m_sb)) {
|
|
|
|
if (mp->m_sb.sb_rblocks) {
|
|
|
|
xfs_alert(mp,
|
2018-02-01 00:38:18 +00:00
|
|
|
"reflink not compatible with realtime device!");
|
2019-02-18 17:38:49 +00:00
|
|
|
error = -EINVAL;
|
|
|
|
goto out_filestream_unmount;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xfs_globals.always_cow) {
|
|
|
|
xfs_info(mp, "using DEBUG-only always_cow mode.");
|
|
|
|
mp->m_always_cow = true;
|
|
|
|
}
|
2018-02-01 00:38:18 +00:00
|
|
|
}
|
|
|
|
|
2018-01-31 17:47:25 +00:00
|
|
|
if (xfs_sb_version_hasrmapbt(&mp->m_sb) && mp->m_sb.sb_rblocks) {
|
2016-08-03 02:20:57 +00:00
|
|
|
xfs_alert(mp,
|
2018-01-31 17:47:25 +00:00
|
|
|
"reverse mapping btree not compatible with realtime device!");
|
|
|
|
error = -EINVAL;
|
|
|
|
goto out_filestream_unmount;
|
2016-08-26 05:59:19 +00:00
|
|
|
}
|
2016-08-03 02:20:57 +00:00
|
|
|
|
2020-08-17 16:58:01 +00:00
|
|
|
if (xfs_sb_version_hasinobtcounts(&mp->m_sb))
|
|
|
|
xfs_warn(mp,
|
|
|
|
"EXPERIMENTAL inode btree counters feature in use. Use at your own risk!");
|
|
|
|
|
2012-04-13 12:10:44 +00:00
|
|
|
error = xfs_mountfs(mp);
|
2011-07-13 11:43:48 +00:00
|
|
|
if (error)
|
2012-10-08 10:56:00 +00:00
|
|
|
goto out_filestream_unmount;
|
2011-03-25 22:14:57 +00:00
|
|
|
|
2008-08-13 05:45:15 +00:00
|
|
|
root = igrab(VFS_I(mp->m_rootip));
|
2008-03-27 07:00:54 +00:00
|
|
|
if (!root) {
|
2014-06-25 04:58:08 +00:00
|
|
|
error = -ENOENT;
|
2012-04-13 12:10:44 +00:00
|
|
|
goto out_unmount;
|
2008-02-05 01:14:01 +00:00
|
|
|
}
|
2012-01-09 03:15:13 +00:00
|
|
|
sb->s_root = d_make_root(root);
|
2008-03-27 07:00:54 +00:00
|
|
|
if (!sb->s_root) {
|
2014-06-25 04:58:08 +00:00
|
|
|
error = -ENOMEM;
|
2012-04-13 12:10:44 +00:00
|
|
|
goto out_unmount;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2007-08-30 07:21:22 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
2012-10-08 10:55:59 +00:00
|
|
|
|
2012-10-08 10:56:00 +00:00
|
|
|
out_filestream_unmount:
|
2008-05-20 05:11:11 +00:00
|
|
|
xfs_filestream_unmount(mp);
|
2008-05-20 05:11:05 +00:00
|
|
|
out_free_sb:
|
|
|
|
xfs_freesb(mp);
|
2015-10-12 07:21:19 +00:00
|
|
|
out_free_stats:
|
|
|
|
free_percpu(mp->m_stats.xs_stats);
|
2008-10-30 06:53:24 +00:00
|
|
|
out_destroy_counters:
|
2015-02-23 10:22:31 +00:00
|
|
|
xfs_destroy_percpu_counters(mp);
|
2015-10-12 07:21:19 +00:00
|
|
|
out_destroy_workqueues:
|
2012-02-29 09:53:48 +00:00
|
|
|
xfs_destroy_mount_workqueues(mp);
|
2010-09-30 02:25:54 +00:00
|
|
|
out_close_devices:
|
2008-05-20 01:31:13 +00:00
|
|
|
xfs_close_devices(mp);
|
2019-11-04 21:58:40 +00:00
|
|
|
out_free_names:
|
2018-05-11 04:50:23 +00:00
|
|
|
sb->s_fs_info = NULL;
|
2019-11-04 21:58:42 +00:00
|
|
|
xfs_mount_free(mp);
|
2014-06-25 04:58:08 +00:00
|
|
|
return error;
|
2008-05-20 01:30:59 +00:00
|
|
|
|
2011-07-13 11:43:48 +00:00
|
|
|
out_unmount:
|
2008-05-20 01:30:52 +00:00
|
|
|
xfs_filestream_unmount(mp);
|
2008-05-20 01:31:13 +00:00
|
|
|
xfs_unmountfs(mp);
|
2008-08-13 06:50:21 +00:00
|
|
|
goto out_free_sb;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2019-11-04 21:58:46 +00:00
|
|
|
static int
|
2020-12-04 23:59:39 +00:00
|
|
|
xfs_fs_get_tree(
|
2019-11-04 21:58:46 +00:00
|
|
|
struct fs_context *fc)
|
|
|
|
{
|
2020-12-04 23:59:39 +00:00
|
|
|
return get_tree_bdev(fc, xfs_fs_fill_super);
|
2019-11-04 21:58:46 +00:00
|
|
|
}
|
|
|
|
|
2019-11-04 21:58:47 +00:00
|
|
|
static int
|
|
|
|
xfs_remount_rw(
|
|
|
|
struct xfs_mount *mp)
|
|
|
|
{
|
|
|
|
struct xfs_sb *sbp = &mp->m_sb;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (mp->m_flags & XFS_MOUNT_NORECOVERY) {
|
|
|
|
xfs_warn(mp,
|
|
|
|
"ro->rw transition prohibited on norecovery mount");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 &&
|
|
|
|
xfs_sb_has_ro_compat_feature(sbp, XFS_SB_FEAT_RO_COMPAT_UNKNOWN)) {
|
|
|
|
xfs_warn(mp,
|
|
|
|
"ro->rw transition prohibited on unknown (0x%x) ro-compat filesystem",
|
|
|
|
(sbp->sb_features_ro_compat &
|
|
|
|
XFS_SB_FEAT_RO_COMPAT_UNKNOWN));
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
mp->m_flags &= ~XFS_MOUNT_RDONLY;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this is the first remount to writeable state we might have some
|
|
|
|
* superblock changes to update.
|
|
|
|
*/
|
|
|
|
if (mp->m_update_sb) {
|
|
|
|
error = xfs_sync_sb(mp, false);
|
|
|
|
if (error) {
|
|
|
|
xfs_warn(mp, "failed to write sb changes");
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
mp->m_update_sb = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill out the reserve pool if it is empty. Use the stashed value if
|
|
|
|
* it is non-zero, otherwise go with the default.
|
|
|
|
*/
|
|
|
|
xfs_restore_resvblks(mp);
|
|
|
|
xfs_log_work_queue(mp);
|
|
|
|
|
|
|
|
/* Recover any CoW blocks that never got remapped. */
|
|
|
|
error = xfs_reflink_recover_cow(mp);
|
|
|
|
if (error) {
|
|
|
|
xfs_err(mp,
|
|
|
|
"Error %d recovering leftover CoW allocations.", error);
|
2019-11-08 16:06:36 +00:00
|
|
|
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
|
2019-11-04 21:58:47 +00:00
|
|
|
return error;
|
|
|
|
}
|
2021-01-23 00:48:44 +00:00
|
|
|
xfs_blockgc_start(mp);
|
2019-11-04 21:58:47 +00:00
|
|
|
|
|
|
|
/* Create the per-AG metadata reservation pool .*/
|
|
|
|
error = xfs_fs_reserve_ag_blocks(mp);
|
|
|
|
if (error && error != -ENOSPC)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
xfs_remount_ro(
|
|
|
|
struct xfs_mount *mp)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cancel background eofb scanning so it cannot race with the final
|
|
|
|
* log force+buftarg wait and deadlock the remount.
|
|
|
|
*/
|
2021-01-23 00:48:44 +00:00
|
|
|
xfs_blockgc_stop(mp);
|
2019-11-04 21:58:47 +00:00
|
|
|
|
|
|
|
/* Get rid of any leftover CoW reservations... */
|
2021-01-23 00:48:40 +00:00
|
|
|
error = xfs_blockgc_free_space(mp, NULL);
|
2019-11-04 21:58:47 +00:00
|
|
|
if (error) {
|
|
|
|
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the per-AG metadata reservation pool. */
|
|
|
|
error = xfs_fs_unreserve_ag_blocks(mp);
|
|
|
|
if (error) {
|
|
|
|
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Before we sync the metadata, we need to free up the reserve block
|
|
|
|
* pool so that the used block count in the superblock on disk is
|
|
|
|
* correct at the end of the remount. Stash the current* reserve pool
|
|
|
|
* size so that if we get remounted rw, we can return it to the same
|
|
|
|
* size.
|
|
|
|
*/
|
|
|
|
xfs_save_resvblks(mp);
|
|
|
|
|
2021-01-23 00:48:24 +00:00
|
|
|
xfs_log_clean(mp);
|
2019-11-04 21:58:47 +00:00
|
|
|
mp->m_flags |= XFS_MOUNT_RDONLY;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Logically we would return an error here to prevent users from believing
|
|
|
|
* they might have changed mount options using remount which can't be changed.
|
|
|
|
*
|
|
|
|
* But unfortunately mount(8) adds all options from mtab and fstab to the mount
|
|
|
|
* arguments in some cases so we can't blindly reject options, but have to
|
|
|
|
* check for each specified option if it actually differs from the currently
|
|
|
|
* set option and only reject it if that's the case.
|
|
|
|
*
|
|
|
|
* Until that is implemented we return success for every remount request, and
|
|
|
|
* silently ignore all options that we can't actually change.
|
|
|
|
*/
|
|
|
|
static int
|
2020-12-04 23:59:39 +00:00
|
|
|
xfs_fs_reconfigure(
|
2019-11-04 21:58:47 +00:00
|
|
|
struct fs_context *fc)
|
|
|
|
{
|
|
|
|
struct xfs_mount *mp = XFS_M(fc->root->d_sb);
|
|
|
|
struct xfs_mount *new_mp = fc->s_fs_info;
|
|
|
|
xfs_sb_t *sbp = &mp->m_sb;
|
|
|
|
int flags = fc->sb_flags;
|
|
|
|
int error;
|
|
|
|
|
2020-07-15 15:30:37 +00:00
|
|
|
/* version 5 superblocks always support version counters. */
|
|
|
|
if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_5)
|
|
|
|
fc->sb_flags |= SB_I_VERSION;
|
|
|
|
|
2020-12-04 23:59:39 +00:00
|
|
|
error = xfs_fs_validate_params(new_mp);
|
2019-11-04 21:58:47 +00:00
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
sync_filesystem(mp->m_super);
|
|
|
|
|
|
|
|
/* inode32 -> inode64 */
|
|
|
|
if ((mp->m_flags & XFS_MOUNT_SMALL_INUMS) &&
|
|
|
|
!(new_mp->m_flags & XFS_MOUNT_SMALL_INUMS)) {
|
|
|
|
mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
|
|
|
|
mp->m_maxagi = xfs_set_inode_alloc(mp, sbp->sb_agcount);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* inode64 -> inode32 */
|
|
|
|
if (!(mp->m_flags & XFS_MOUNT_SMALL_INUMS) &&
|
|
|
|
(new_mp->m_flags & XFS_MOUNT_SMALL_INUMS)) {
|
|
|
|
mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
|
|
|
|
mp->m_maxagi = xfs_set_inode_alloc(mp, sbp->sb_agcount);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ro -> rw */
|
|
|
|
if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(flags & SB_RDONLY)) {
|
|
|
|
error = xfs_remount_rw(mp);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* rw -> ro */
|
|
|
|
if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (flags & SB_RDONLY)) {
|
|
|
|
error = xfs_remount_ro(mp);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-12-04 23:59:39 +00:00
|
|
|
static void xfs_fs_free(
|
2019-11-04 21:58:46 +00:00
|
|
|
struct fs_context *fc)
|
|
|
|
{
|
|
|
|
struct xfs_mount *mp = fc->s_fs_info;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* mp is stored in the fs_context when it is initialized.
|
|
|
|
* mp is transferred to the superblock on a successful mount,
|
|
|
|
* but if an error occurs before the transfer we have to free
|
|
|
|
* it here.
|
|
|
|
*/
|
|
|
|
if (mp)
|
|
|
|
xfs_mount_free(mp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct fs_context_operations xfs_context_ops = {
|
2020-12-04 23:59:39 +00:00
|
|
|
.parse_param = xfs_fs_parse_param,
|
|
|
|
.get_tree = xfs_fs_get_tree,
|
|
|
|
.reconfigure = xfs_fs_reconfigure,
|
|
|
|
.free = xfs_fs_free,
|
2019-11-04 21:58:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int xfs_init_fs_context(
|
|
|
|
struct fs_context *fc)
|
|
|
|
{
|
|
|
|
struct xfs_mount *mp;
|
|
|
|
|
2019-11-04 21:58:48 +00:00
|
|
|
mp = kmem_alloc(sizeof(struct xfs_mount), KM_ZERO);
|
2019-11-04 21:58:46 +00:00
|
|
|
if (!mp)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2019-11-04 21:58:48 +00:00
|
|
|
spin_lock_init(&mp->m_sb_lock);
|
|
|
|
spin_lock_init(&mp->m_agirotor_lock);
|
|
|
|
INIT_RADIX_TREE(&mp->m_perag_tree, GFP_ATOMIC);
|
|
|
|
spin_lock_init(&mp->m_perag_lock);
|
|
|
|
mutex_init(&mp->m_growlock);
|
2020-04-12 20:11:10 +00:00
|
|
|
INIT_WORK(&mp->m_flush_inodes_work, xfs_flush_inodes_worker);
|
2019-11-04 21:58:48 +00:00
|
|
|
INIT_DELAYED_WORK(&mp->m_reclaim_work, xfs_reclaim_worker);
|
|
|
|
mp->m_kobj.kobject.kset = xfs_kset;
|
|
|
|
/*
|
|
|
|
* We don't create the finobt per-ag space reservation until after log
|
|
|
|
* recovery, so we must set this to true so that an ifree transaction
|
|
|
|
* started during log recovery will not depend on space reservations
|
|
|
|
* for finobt expansion.
|
|
|
|
*/
|
|
|
|
mp->m_finobt_nores = true;
|
|
|
|
|
2019-11-04 21:58:46 +00:00
|
|
|
/*
|
|
|
|
* These can be overridden by the mount option parsing.
|
|
|
|
*/
|
|
|
|
mp->m_logbufs = -1;
|
|
|
|
mp->m_logbsize = -1;
|
|
|
|
mp->m_allocsize_log = 16; /* 64k */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy binary VFS mount flags we are interested in.
|
|
|
|
*/
|
|
|
|
if (fc->sb_flags & SB_RDONLY)
|
|
|
|
mp->m_flags |= XFS_MOUNT_RDONLY;
|
|
|
|
if (fc->sb_flags & SB_DIRSYNC)
|
|
|
|
mp->m_flags |= XFS_MOUNT_DIRSYNC;
|
|
|
|
if (fc->sb_flags & SB_SYNCHRONOUS)
|
|
|
|
mp->m_flags |= XFS_MOUNT_WSYNC;
|
|
|
|
|
|
|
|
fc->s_fs_info = mp;
|
|
|
|
fc->ops = &xfs_context_ops;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-02-20 21:57:47 +00:00
|
|
|
static struct file_system_type xfs_fs_type = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "xfs",
|
2019-11-04 21:58:46 +00:00
|
|
|
.init_fs_context = xfs_init_fs_context,
|
2019-09-07 11:23:15 +00:00
|
|
|
.parameters = xfs_fs_parameters,
|
2005-04-16 22:20:36 +00:00
|
|
|
.kill_sb = kill_block_super,
|
2021-01-21 13:19:58 +00:00
|
|
|
.fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
2013-03-03 03:39:14 +00:00
|
|
|
MODULE_ALIAS_FS("xfs");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-07-18 07:11:46 +00:00
|
|
|
STATIC int __init
|
|
|
|
xfs_init_zones(void)
|
|
|
|
{
|
2019-11-14 20:43:03 +00:00
|
|
|
xfs_log_ticket_zone = kmem_cache_create("xfs_log_ticket",
|
|
|
|
sizeof(struct xlog_ticket),
|
|
|
|
0, 0, NULL);
|
2008-07-18 07:11:46 +00:00
|
|
|
if (!xfs_log_ticket_zone)
|
2019-10-17 20:12:15 +00:00
|
|
|
goto out;
|
2008-07-18 07:11:46 +00:00
|
|
|
|
2019-11-14 20:43:03 +00:00
|
|
|
xfs_bmap_free_item_zone = kmem_cache_create("xfs_bmap_free_item",
|
|
|
|
sizeof(struct xfs_extent_free_item),
|
|
|
|
0, 0, NULL);
|
2008-07-18 07:11:46 +00:00
|
|
|
if (!xfs_bmap_free_item_zone)
|
|
|
|
goto out_destroy_log_ticket_zone;
|
2008-10-30 06:36:14 +00:00
|
|
|
|
2019-11-14 20:43:03 +00:00
|
|
|
xfs_btree_cur_zone = kmem_cache_create("xfs_btree_cur",
|
|
|
|
sizeof(struct xfs_btree_cur),
|
|
|
|
0, 0, NULL);
|
2008-07-18 07:11:46 +00:00
|
|
|
if (!xfs_btree_cur_zone)
|
|
|
|
goto out_destroy_bmap_free_item_zone;
|
|
|
|
|
2019-11-14 20:43:03 +00:00
|
|
|
xfs_da_state_zone = kmem_cache_create("xfs_da_state",
|
|
|
|
sizeof(struct xfs_da_state),
|
|
|
|
0, 0, NULL);
|
2008-07-18 07:11:46 +00:00
|
|
|
if (!xfs_da_state_zone)
|
|
|
|
goto out_destroy_btree_cur_zone;
|
|
|
|
|
2019-11-14 20:43:03 +00:00
|
|
|
xfs_ifork_zone = kmem_cache_create("xfs_ifork",
|
|
|
|
sizeof(struct xfs_ifork),
|
|
|
|
0, 0, NULL);
|
2008-07-18 07:11:46 +00:00
|
|
|
if (!xfs_ifork_zone)
|
2012-06-22 08:50:14 +00:00
|
|
|
goto out_destroy_da_state_zone;
|
2008-07-18 07:11:46 +00:00
|
|
|
|
2021-03-25 18:47:05 +00:00
|
|
|
xfs_trans_zone = kmem_cache_create("xfs_trans",
|
2019-11-14 20:43:03 +00:00
|
|
|
sizeof(struct xfs_trans),
|
|
|
|
0, 0, NULL);
|
2008-07-18 07:11:46 +00:00
|
|
|
if (!xfs_trans_zone)
|
|
|
|
goto out_destroy_ifork_zone;
|
|
|
|
|
2010-06-23 08:11:15 +00:00
|
|
|
|
2008-07-18 07:11:46 +00:00
|
|
|
/*
|
|
|
|
* The size of the zone allocated buf log item is the maximum
|
|
|
|
* size possible under XFS. This wastes a little bit of memory,
|
|
|
|
* but it is much faster.
|
|
|
|
*/
|
2019-11-14 20:43:03 +00:00
|
|
|
xfs_buf_item_zone = kmem_cache_create("xfs_buf_item",
|
|
|
|
sizeof(struct xfs_buf_log_item),
|
|
|
|
0, 0, NULL);
|
2008-07-18 07:11:46 +00:00
|
|
|
if (!xfs_buf_item_zone)
|
2018-05-09 14:49:37 +00:00
|
|
|
goto out_destroy_trans_zone;
|
2008-07-18 07:11:46 +00:00
|
|
|
|
2019-11-14 20:43:03 +00:00
|
|
|
xfs_efd_zone = kmem_cache_create("xfs_efd_item",
|
|
|
|
(sizeof(struct xfs_efd_log_item) +
|
|
|
|
(XFS_EFD_MAX_FAST_EXTENTS - 1) *
|
|
|
|
sizeof(struct xfs_extent)),
|
|
|
|
0, 0, NULL);
|
2008-07-18 07:11:46 +00:00
|
|
|
if (!xfs_efd_zone)
|
|
|
|
goto out_destroy_buf_item_zone;
|
|
|
|
|
2019-11-14 20:43:03 +00:00
|
|
|
xfs_efi_zone = kmem_cache_create("xfs_efi_item",
|
|
|
|
(sizeof(struct xfs_efi_log_item) +
|
|
|
|
(XFS_EFI_MAX_FAST_EXTENTS - 1) *
|
|
|
|
sizeof(struct xfs_extent)),
|
|
|
|
0, 0, NULL);
|
2008-07-18 07:11:46 +00:00
|
|
|
if (!xfs_efi_zone)
|
|
|
|
goto out_destroy_efd_zone;
|
|
|
|
|
2019-11-14 20:43:03 +00:00
|
|
|
xfs_inode_zone = kmem_cache_create("xfs_inode",
|
|
|
|
sizeof(struct xfs_inode), 0,
|
|
|
|
(SLAB_HWCACHE_ALIGN |
|
|
|
|
SLAB_RECLAIM_ACCOUNT |
|
|
|
|
SLAB_MEM_SPREAD | SLAB_ACCOUNT),
|
|
|
|
xfs_fs_inode_init_once);
|
2008-07-18 07:11:46 +00:00
|
|
|
if (!xfs_inode_zone)
|
|
|
|
goto out_destroy_efi_zone;
|
|
|
|
|
2019-11-14 20:43:03 +00:00
|
|
|
xfs_ili_zone = kmem_cache_create("xfs_ili",
|
|
|
|
sizeof(struct xfs_inode_log_item), 0,
|
2020-03-25 03:10:28 +00:00
|
|
|
SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD,
|
|
|
|
NULL);
|
2008-07-18 07:11:46 +00:00
|
|
|
if (!xfs_ili_zone)
|
|
|
|
goto out_destroy_inode_zone;
|
2019-11-14 20:43:03 +00:00
|
|
|
|
|
|
|
xfs_icreate_zone = kmem_cache_create("xfs_icr",
|
|
|
|
sizeof(struct xfs_icreate_item),
|
|
|
|
0, 0, NULL);
|
2013-06-27 06:04:53 +00:00
|
|
|
if (!xfs_icreate_zone)
|
|
|
|
goto out_destroy_ili_zone;
|
2008-07-18 07:11:46 +00:00
|
|
|
|
2019-11-14 20:43:03 +00:00
|
|
|
xfs_rud_zone = kmem_cache_create("xfs_rud_item",
|
|
|
|
sizeof(struct xfs_rud_log_item),
|
|
|
|
0, 0, NULL);
|
2016-08-03 02:04:45 +00:00
|
|
|
if (!xfs_rud_zone)
|
|
|
|
goto out_destroy_icreate_zone;
|
|
|
|
|
2019-11-14 20:43:03 +00:00
|
|
|
xfs_rui_zone = kmem_cache_create("xfs_rui_item",
|
2016-09-19 00:24:27 +00:00
|
|
|
xfs_rui_log_item_sizeof(XFS_RUI_MAX_FAST_EXTENTS),
|
2019-11-14 20:43:03 +00:00
|
|
|
0, 0, NULL);
|
2016-08-03 02:04:45 +00:00
|
|
|
if (!xfs_rui_zone)
|
|
|
|
goto out_destroy_rud_zone;
|
|
|
|
|
2019-11-14 20:43:03 +00:00
|
|
|
xfs_cud_zone = kmem_cache_create("xfs_cud_item",
|
|
|
|
sizeof(struct xfs_cud_log_item),
|
|
|
|
0, 0, NULL);
|
2016-10-03 16:11:20 +00:00
|
|
|
if (!xfs_cud_zone)
|
|
|
|
goto out_destroy_rui_zone;
|
|
|
|
|
2019-11-14 20:43:03 +00:00
|
|
|
xfs_cui_zone = kmem_cache_create("xfs_cui_item",
|
2016-10-03 16:11:20 +00:00
|
|
|
xfs_cui_log_item_sizeof(XFS_CUI_MAX_FAST_EXTENTS),
|
2019-11-14 20:43:03 +00:00
|
|
|
0, 0, NULL);
|
2016-10-03 16:11:20 +00:00
|
|
|
if (!xfs_cui_zone)
|
|
|
|
goto out_destroy_cud_zone;
|
|
|
|
|
2019-11-14 20:43:03 +00:00
|
|
|
xfs_bud_zone = kmem_cache_create("xfs_bud_item",
|
|
|
|
sizeof(struct xfs_bud_log_item),
|
|
|
|
0, 0, NULL);
|
2016-10-03 16:11:25 +00:00
|
|
|
if (!xfs_bud_zone)
|
|
|
|
goto out_destroy_cui_zone;
|
|
|
|
|
2019-11-14 20:43:03 +00:00
|
|
|
xfs_bui_zone = kmem_cache_create("xfs_bui_item",
|
2016-10-03 16:11:25 +00:00
|
|
|
xfs_bui_log_item_sizeof(XFS_BUI_MAX_FAST_EXTENTS),
|
2019-11-14 20:43:03 +00:00
|
|
|
0, 0, NULL);
|
2016-10-03 16:11:25 +00:00
|
|
|
if (!xfs_bui_zone)
|
|
|
|
goto out_destroy_bud_zone;
|
|
|
|
|
2008-07-18 07:11:46 +00:00
|
|
|
return 0;
|
|
|
|
|
2016-10-03 16:11:25 +00:00
|
|
|
out_destroy_bud_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_bud_zone);
|
2016-10-03 16:11:25 +00:00
|
|
|
out_destroy_cui_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_cui_zone);
|
2016-10-03 16:11:20 +00:00
|
|
|
out_destroy_cud_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_cud_zone);
|
2016-10-03 16:11:20 +00:00
|
|
|
out_destroy_rui_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_rui_zone);
|
2016-08-03 02:04:45 +00:00
|
|
|
out_destroy_rud_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_rud_zone);
|
2016-08-03 02:04:45 +00:00
|
|
|
out_destroy_icreate_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_icreate_zone);
|
2013-06-27 06:04:53 +00:00
|
|
|
out_destroy_ili_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_ili_zone);
|
2008-07-18 07:11:46 +00:00
|
|
|
out_destroy_inode_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_inode_zone);
|
2008-07-18 07:11:46 +00:00
|
|
|
out_destroy_efi_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_efi_zone);
|
2008-07-18 07:11:46 +00:00
|
|
|
out_destroy_efd_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_efd_zone);
|
2008-07-18 07:11:46 +00:00
|
|
|
out_destroy_buf_item_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_buf_item_zone);
|
2008-07-18 07:11:46 +00:00
|
|
|
out_destroy_trans_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_trans_zone);
|
2008-07-18 07:11:46 +00:00
|
|
|
out_destroy_ifork_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_ifork_zone);
|
2008-07-18 07:11:46 +00:00
|
|
|
out_destroy_da_state_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_da_state_zone);
|
2008-07-18 07:11:46 +00:00
|
|
|
out_destroy_btree_cur_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_btree_cur_zone);
|
2008-07-18 07:11:46 +00:00
|
|
|
out_destroy_bmap_free_item_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_bmap_free_item_zone);
|
2008-07-18 07:11:46 +00:00
|
|
|
out_destroy_log_ticket_zone:
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_log_ticket_zone);
|
2008-07-18 07:11:46 +00:00
|
|
|
out:
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
STATIC void
|
|
|
|
xfs_destroy_zones(void)
|
|
|
|
{
|
2012-09-26 01:33:07 +00:00
|
|
|
/*
|
|
|
|
* Make sure all delayed rcu free are flushed before we
|
|
|
|
* destroy caches.
|
|
|
|
*/
|
|
|
|
rcu_barrier();
|
2019-11-14 20:43:04 +00:00
|
|
|
kmem_cache_destroy(xfs_bui_zone);
|
|
|
|
kmem_cache_destroy(xfs_bud_zone);
|
|
|
|
kmem_cache_destroy(xfs_cui_zone);
|
|
|
|
kmem_cache_destroy(xfs_cud_zone);
|
|
|
|
kmem_cache_destroy(xfs_rui_zone);
|
|
|
|
kmem_cache_destroy(xfs_rud_zone);
|
|
|
|
kmem_cache_destroy(xfs_icreate_zone);
|
|
|
|
kmem_cache_destroy(xfs_ili_zone);
|
|
|
|
kmem_cache_destroy(xfs_inode_zone);
|
|
|
|
kmem_cache_destroy(xfs_efi_zone);
|
|
|
|
kmem_cache_destroy(xfs_efd_zone);
|
|
|
|
kmem_cache_destroy(xfs_buf_item_zone);
|
|
|
|
kmem_cache_destroy(xfs_trans_zone);
|
|
|
|
kmem_cache_destroy(xfs_ifork_zone);
|
|
|
|
kmem_cache_destroy(xfs_da_state_zone);
|
|
|
|
kmem_cache_destroy(xfs_btree_cur_zone);
|
|
|
|
kmem_cache_destroy(xfs_bmap_free_item_zone);
|
|
|
|
kmem_cache_destroy(xfs_log_ticket_zone);
|
2008-07-18 07:11:46 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-04-08 02:45:07 +00:00
|
|
|
STATIC int __init
|
|
|
|
xfs_init_workqueues(void)
|
|
|
|
{
|
2012-03-22 05:15:07 +00:00
|
|
|
/*
|
|
|
|
* The allocation workqueue can be used in memory reclaim situations
|
|
|
|
* (writepage path), and parallelism is only limited by the number of
|
|
|
|
* AGs in all the filesystems mounted. Hence use the default large
|
|
|
|
* max_active value for this workqueue.
|
|
|
|
*/
|
2014-09-09 01:44:46 +00:00
|
|
|
xfs_alloc_wq = alloc_workqueue("xfsalloc",
|
2021-01-23 00:48:42 +00:00
|
|
|
XFS_WQFLAGS(WQ_MEM_RECLAIM | WQ_FREEZABLE), 0);
|
2012-03-22 05:15:07 +00:00
|
|
|
if (!xfs_alloc_wq)
|
2012-10-08 10:56:05 +00:00
|
|
|
return -ENOMEM;
|
2012-03-22 05:15:07 +00:00
|
|
|
|
2021-01-23 00:48:42 +00:00
|
|
|
xfs_discard_wq = alloc_workqueue("xfsdiscard", XFS_WQFLAGS(WQ_UNBOUND),
|
|
|
|
0);
|
2017-02-07 22:07:58 +00:00
|
|
|
if (!xfs_discard_wq)
|
|
|
|
goto out_free_alloc_wq;
|
|
|
|
|
2011-04-08 02:45:07 +00:00
|
|
|
return 0;
|
2017-02-07 22:07:58 +00:00
|
|
|
out_free_alloc_wq:
|
|
|
|
destroy_workqueue(xfs_alloc_wq);
|
|
|
|
return -ENOMEM;
|
2011-04-08 02:45:07 +00:00
|
|
|
}
|
|
|
|
|
2011-04-11 19:06:12 +00:00
|
|
|
STATIC void
|
2011-04-08 02:45:07 +00:00
|
|
|
xfs_destroy_workqueues(void)
|
|
|
|
{
|
2017-02-07 22:07:58 +00:00
|
|
|
destroy_workqueue(xfs_discard_wq);
|
2012-03-22 05:15:07 +00:00
|
|
|
destroy_workqueue(xfs_alloc_wq);
|
2011-04-08 02:45:07 +00:00
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
STATIC int __init
|
2008-07-18 07:11:46 +00:00
|
|
|
init_xfs_fs(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
2016-03-08 21:15:14 +00:00
|
|
|
xfs_check_ondisk_structs();
|
|
|
|
|
2008-11-28 03:23:33 +00:00
|
|
|
printk(KERN_INFO XFS_VERSION_STRING " with "
|
|
|
|
XFS_BUILD_OPTIONS " enabled\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-07-18 07:11:46 +00:00
|
|
|
xfs_dir_startup();
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-03-14 02:18:19 +00:00
|
|
|
error = xfs_init_zones();
|
2008-07-18 07:11:46 +00:00
|
|
|
if (error)
|
|
|
|
goto out;
|
|
|
|
|
2011-04-08 02:45:07 +00:00
|
|
|
error = xfs_init_workqueues();
|
2008-07-18 07:11:46 +00:00
|
|
|
if (error)
|
2009-12-14 23:14:59 +00:00
|
|
|
goto out_destroy_zones;
|
2008-07-18 07:11:46 +00:00
|
|
|
|
2011-04-08 02:45:07 +00:00
|
|
|
error = xfs_mru_cache_init();
|
|
|
|
if (error)
|
|
|
|
goto out_destroy_wq;
|
|
|
|
|
2006-01-11 04:39:08 +00:00
|
|
|
error = xfs_buf_init();
|
2008-07-18 07:11:46 +00:00
|
|
|
if (error)
|
2014-04-22 21:11:51 +00:00
|
|
|
goto out_mru_cache_uninit;
|
2008-07-18 07:11:46 +00:00
|
|
|
|
|
|
|
error = xfs_init_procfs();
|
|
|
|
if (error)
|
|
|
|
goto out_buf_terminate;
|
|
|
|
|
|
|
|
error = xfs_sysctl_register();
|
|
|
|
if (error)
|
|
|
|
goto out_cleanup_procfs;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2014-07-14 21:41:37 +00:00
|
|
|
xfs_kset = kset_create_and_add("xfs", NULL, fs_kobj);
|
|
|
|
if (!xfs_kset) {
|
|
|
|
error = -ENOMEM;
|
2015-10-11 18:15:45 +00:00
|
|
|
goto out_sysctl_unregister;
|
2014-07-14 21:41:37 +00:00
|
|
|
}
|
|
|
|
|
2015-10-11 18:19:45 +00:00
|
|
|
xfsstats.xs_kobj.kobject.kset = xfs_kset;
|
|
|
|
|
|
|
|
xfsstats.xs_stats = alloc_percpu(struct xfsstats);
|
|
|
|
if (!xfsstats.xs_stats) {
|
|
|
|
error = -ENOMEM;
|
|
|
|
goto out_kset_unregister;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = xfs_sysfs_init(&xfsstats.xs_kobj, &xfs_stats_ktype, NULL,
|
2015-10-11 18:15:45 +00:00
|
|
|
"stats");
|
|
|
|
if (error)
|
2015-10-11 18:19:45 +00:00
|
|
|
goto out_free_stats;
|
2015-10-11 18:15:45 +00:00
|
|
|
|
2014-09-09 01:52:42 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
xfs_dbg_kobj.kobject.kset = xfs_kset;
|
|
|
|
error = xfs_sysfs_init(&xfs_dbg_kobj, &xfs_dbg_ktype, NULL, "debug");
|
2012-03-13 08:52:37 +00:00
|
|
|
if (error)
|
2015-10-11 18:15:45 +00:00
|
|
|
goto out_remove_stats_kobj;
|
2014-09-09 01:52:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
error = xfs_qm_init();
|
|
|
|
if (error)
|
2015-10-11 18:15:45 +00:00
|
|
|
goto out_remove_dbg_kobj;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
error = register_filesystem(&xfs_fs_type);
|
|
|
|
if (error)
|
2012-03-13 08:52:37 +00:00
|
|
|
goto out_qm_exit;
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
|
2012-03-13 08:52:37 +00:00
|
|
|
out_qm_exit:
|
|
|
|
xfs_qm_exit();
|
2015-10-11 18:15:45 +00:00
|
|
|
out_remove_dbg_kobj:
|
2014-09-09 01:52:42 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
xfs_sysfs_del(&xfs_dbg_kobj);
|
2015-10-11 18:15:45 +00:00
|
|
|
out_remove_stats_kobj:
|
2014-09-09 01:52:42 +00:00
|
|
|
#endif
|
2015-10-11 18:19:45 +00:00
|
|
|
xfs_sysfs_del(&xfsstats.xs_kobj);
|
|
|
|
out_free_stats:
|
|
|
|
free_percpu(xfsstats.xs_stats);
|
2015-10-11 18:15:45 +00:00
|
|
|
out_kset_unregister:
|
2014-07-14 21:41:37 +00:00
|
|
|
kset_unregister(xfs_kset);
|
2008-07-18 07:11:46 +00:00
|
|
|
out_sysctl_unregister:
|
|
|
|
xfs_sysctl_unregister();
|
|
|
|
out_cleanup_procfs:
|
|
|
|
xfs_cleanup_procfs();
|
|
|
|
out_buf_terminate:
|
2006-01-11 04:39:08 +00:00
|
|
|
xfs_buf_terminate();
|
2008-07-18 07:11:46 +00:00
|
|
|
out_mru_cache_uninit:
|
|
|
|
xfs_mru_cache_uninit();
|
2011-04-08 02:45:07 +00:00
|
|
|
out_destroy_wq:
|
|
|
|
xfs_destroy_workqueues();
|
2008-07-18 07:11:46 +00:00
|
|
|
out_destroy_zones:
|
2006-03-14 02:18:19 +00:00
|
|
|
xfs_destroy_zones();
|
2008-07-18 07:11:46 +00:00
|
|
|
out:
|
2005-04-16 22:20:36 +00:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
STATIC void __exit
|
2008-07-18 07:11:46 +00:00
|
|
|
exit_xfs_fs(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2012-03-13 08:52:37 +00:00
|
|
|
xfs_qm_exit();
|
2005-04-16 22:20:36 +00:00
|
|
|
unregister_filesystem(&xfs_fs_type);
|
2014-09-09 01:52:42 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
xfs_sysfs_del(&xfs_dbg_kobj);
|
|
|
|
#endif
|
2015-10-11 18:19:45 +00:00
|
|
|
xfs_sysfs_del(&xfsstats.xs_kobj);
|
|
|
|
free_percpu(xfsstats.xs_stats);
|
2014-07-14 21:41:37 +00:00
|
|
|
kset_unregister(xfs_kset);
|
2008-07-18 07:11:46 +00:00
|
|
|
xfs_sysctl_unregister();
|
|
|
|
xfs_cleanup_procfs();
|
2006-01-11 04:39:08 +00:00
|
|
|
xfs_buf_terminate();
|
2008-07-18 07:11:46 +00:00
|
|
|
xfs_mru_cache_uninit();
|
2011-04-08 02:45:07 +00:00
|
|
|
xfs_destroy_workqueues();
|
2006-03-14 02:18:19 +00:00
|
|
|
xfs_destroy_zones();
|
2015-11-03 02:06:34 +00:00
|
|
|
xfs_uuid_table_free();
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(init_xfs_fs);
|
|
|
|
module_exit(exit_xfs_fs);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Silicon Graphics, Inc.");
|
|
|
|
MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
|
|
|
|
MODULE_LICENSE("GPL");
|