2005-04-17 05:20:36 +07:00
|
|
|
/*
|
2005-11-02 10:58:39 +07:00
|
|
|
* Copyright (c) 2000-2005 Silicon Graphics, Inc.
|
|
|
|
* All Rights Reserved.
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
2005-11-02 10:58:39 +07:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
2005-04-17 05:20:36 +07:00
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
2005-11-02 10:58:39 +07:00
|
|
|
* This program is distributed in the hope that it would be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
2005-11-02 10:58:39 +07:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
#include "xfs.h"
|
2005-11-02 10:38:42 +07:00
|
|
|
#include "xfs_fs.h"
|
2005-04-17 05:20:36 +07:00
|
|
|
#include "xfs_types.h"
|
|
|
|
#include "xfs_log.h"
|
2005-11-02 10:38:42 +07:00
|
|
|
#include "xfs_inum.h"
|
2005-04-17 05:20:36 +07:00
|
|
|
#include "xfs_trans.h"
|
|
|
|
#include "xfs_sb.h"
|
|
|
|
#include "xfs_ag.h"
|
|
|
|
#include "xfs_dir2.h"
|
|
|
|
#include "xfs_dmapi.h"
|
|
|
|
#include "xfs_mount.h"
|
2005-09-05 05:24:10 +07:00
|
|
|
#include "xfs_quota.h"
|
|
|
|
#include "xfs_error.h"
|
2007-08-30 14:19:57 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
STATIC struct xfs_dquot *
|
|
|
|
xfs_dqvopchown_default(
|
|
|
|
struct xfs_trans *tp,
|
|
|
|
struct xfs_inode *ip,
|
|
|
|
struct xfs_dquot **dqp,
|
|
|
|
struct xfs_dquot *dq)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-09-05 05:24:10 +07:00
|
|
|
/*
|
|
|
|
* Clear the quotaflags in memory and in the superblock.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
xfs_mount_reset_sbqflags(xfs_mount_t *mp)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
xfs_trans_t *tp;
|
|
|
|
|
|
|
|
mp->m_qflags = 0;
|
|
|
|
/*
|
|
|
|
* It is OK to look at sb_qflags here in mount path,
|
2007-10-11 14:42:32 +07:00
|
|
|
* without m_sb_lock.
|
2005-09-05 05:24:10 +07:00
|
|
|
*/
|
|
|
|
if (mp->m_sb.sb_qflags == 0)
|
|
|
|
return 0;
|
2007-10-11 14:42:32 +07:00
|
|
|
spin_lock(&mp->m_sb_lock);
|
2005-09-05 05:24:10 +07:00
|
|
|
mp->m_sb.sb_qflags = 0;
|
2007-10-11 14:42:32 +07:00
|
|
|
spin_unlock(&mp->m_sb_lock);
|
2005-09-05 05:24:10 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* if the fs is readonly, let the incore superblock run
|
|
|
|
* with quotas off but don't flush the update out to disk
|
|
|
|
*/
|
2007-08-30 14:21:12 +07:00
|
|
|
if (mp->m_flags & XFS_MOUNT_RDONLY)
|
2005-09-05 05:24:10 +07:00
|
|
|
return 0;
|
|
|
|
#ifdef QUOTADEBUG
|
|
|
|
xfs_fs_cmn_err(CE_NOTE, mp, "Writing superblock quota changes");
|
|
|
|
#endif
|
|
|
|
tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE);
|
|
|
|
if ((error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0,
|
|
|
|
XFS_DEFAULT_LOG_COUNT))) {
|
|
|
|
xfs_trans_cancel(tp, 0);
|
|
|
|
xfs_fs_cmn_err(CE_ALERT, mp,
|
|
|
|
"xfs_mount_reset_sbqflags: Superblock update failed!");
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
xfs_mod_sb(tp, XFS_SB_QFLAGS);
|
2007-05-08 10:48:42 +07:00
|
|
|
error = xfs_trans_commit(tp, 0);
|
2005-09-05 05:24:10 +07:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
STATIC int
|
|
|
|
xfs_noquota_init(
|
|
|
|
xfs_mount_t *mp,
|
|
|
|
uint *needquotamount,
|
|
|
|
uint *quotaflags)
|
|
|
|
{
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
*quotaflags = 0;
|
|
|
|
*needquotamount = B_FALSE;
|
|
|
|
|
|
|
|
ASSERT(!XFS_IS_QUOTA_ON(mp));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If a file system had quotas running earlier, but decided to
|
|
|
|
* mount without -o uquota/pquota/gquota options, revoke the
|
|
|
|
* quotachecked license.
|
|
|
|
*/
|
|
|
|
if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT) {
|
|
|
|
cmn_err(CE_NOTE,
|
|
|
|
"XFS resetting qflags for filesystem %s",
|
|
|
|
mp->m_fsname);
|
|
|
|
|
|
|
|
error = xfs_mount_reset_sbqflags(mp);
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2007-08-30 14:19:57 +07:00
|
|
|
static struct xfs_qmops xfs_qmcore_stub = {
|
2005-09-05 05:24:10 +07:00
|
|
|
.xfs_qminit = (xfs_qminit_t) xfs_noquota_init,
|
2005-04-17 05:20:36 +07:00
|
|
|
.xfs_qmdone = (xfs_qmdone_t) fs_noerr,
|
|
|
|
.xfs_qmmount = (xfs_qmmount_t) fs_noerr,
|
|
|
|
.xfs_qmunmount = (xfs_qmunmount_t) fs_noerr,
|
|
|
|
.xfs_dqrele = (xfs_dqrele_t) fs_noerr,
|
|
|
|
.xfs_dqattach = (xfs_dqattach_t) fs_noerr,
|
|
|
|
.xfs_dqdetach = (xfs_dqdetach_t) fs_noerr,
|
|
|
|
.xfs_dqpurgeall = (xfs_dqpurgeall_t) fs_noerr,
|
|
|
|
.xfs_dqvopalloc = (xfs_dqvopalloc_t) fs_noerr,
|
|
|
|
.xfs_dqvopcreate = (xfs_dqvopcreate_t) fs_noerr,
|
|
|
|
.xfs_dqvoprename = (xfs_dqvoprename_t) fs_noerr,
|
|
|
|
.xfs_dqvopchown = xfs_dqvopchown_default,
|
|
|
|
.xfs_dqvopchownresv = (xfs_dqvopchownresv_t) fs_noerr,
|
2007-08-30 14:19:57 +07:00
|
|
|
.xfs_dqstatvfs = (xfs_dqstatvfs_t) fs_noval,
|
|
|
|
.xfs_dqsync = (xfs_dqsync_t) fs_noerr,
|
|
|
|
.xfs_quotactl = (xfs_quotactl_t) fs_nosys,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
2007-08-30 14:19:57 +07:00
|
|
|
|
|
|
|
int
|
2008-10-30 13:53:24 +07:00
|
|
|
xfs_qmops_get(struct xfs_mount *mp)
|
2007-08-30 14:19:57 +07:00
|
|
|
{
|
2008-10-30 13:53:24 +07:00
|
|
|
if (XFS_IS_QUOTA_RUNNING(mp)) {
|
2007-10-19 13:57:01 +07:00
|
|
|
#ifdef CONFIG_XFS_QUOTA
|
|
|
|
mp->m_qm_ops = &xfs_qmcore_xfs;
|
|
|
|
#else
|
|
|
|
cmn_err(CE_WARN,
|
|
|
|
"XFS: qouta support not available in this kernel.");
|
|
|
|
return EINVAL;
|
|
|
|
#endif
|
2007-08-30 14:19:57 +07:00
|
|
|
} else {
|
|
|
|
mp->m_qm_ops = &xfs_qmcore_stub;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
xfs_qmops_put(struct xfs_mount *mp)
|
|
|
|
{
|
|
|
|
}
|