Commit 55622c6d authored by Lachlan McIlroy's avatar Lachlan McIlroy Committed by Lachlan McIlroy

Merge branch 'master' of git://git.kernel.org/pub/scm/fs/xfs/xfs

parents 6c5200ce 2809f76a
config XFS_FS config XFS_FS
tristate "XFS filesystem support" tristate "XFS filesystem support"
depends on BLOCK depends on BLOCK
select EXPORTFS
help help
XFS is a high performance journaling filesystem which originated XFS is a high performance journaling filesystem which originated
on the SGI IRIX platform. It is completely multi-threaded, can on the SGI IRIX platform. It is completely multi-threaded, can
......
This diff is collapsed.
...@@ -34,16 +34,13 @@ xfs_find_handle( ...@@ -34,16 +34,13 @@ xfs_find_handle(
extern int extern int
xfs_open_by_handle( xfs_open_by_handle(
xfs_mount_t *mp,
xfs_fsop_handlereq_t *hreq,
struct file *parfilp, struct file *parfilp,
struct inode *parinode); xfs_fsop_handlereq_t *hreq);
extern int extern int
xfs_readlink_by_handle( xfs_readlink_by_handle(
xfs_mount_t *mp, struct file *parfilp,
xfs_fsop_handlereq_t *hreq, xfs_fsop_handlereq_t *hreq);
struct inode *parinode);
extern int extern int
xfs_attrmulti_attr_get( xfs_attrmulti_attr_get(
...@@ -67,6 +64,12 @@ xfs_attrmulti_attr_remove( ...@@ -67,6 +64,12 @@ xfs_attrmulti_attr_remove(
char *name, char *name,
__uint32_t flags); __uint32_t flags);
extern struct dentry *
xfs_handle_to_dentry(
struct file *parfilp,
void __user *uhandle,
u32 hlen);
extern long extern long
xfs_file_ioctl( xfs_file_ioctl(
struct file *filp, struct file *filp,
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*/ */
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/ioctl.h> #include <linux/ioctl.h>
#include <linux/mount.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
...@@ -340,96 +341,24 @@ xfs_compat_handlereq_copyin( ...@@ -340,96 +341,24 @@ xfs_compat_handlereq_copyin(
return 0; return 0;
} }
/* STATIC struct dentry *
* Convert userspace handle data into inode. xfs_compat_handlereq_to_dentry(
* struct file *parfilp,
* We use the fact that all the fsop_handlereq ioctl calls have a data compat_xfs_fsop_handlereq_t *hreq)
* structure argument whose first component is always a xfs_fsop_handlereq_t,
* so we can pass that sub structure into this handy, shared routine.
*
* If no error, caller must always iput the returned inode.
*/
STATIC int
xfs_vget_fsop_handlereq_compat(
xfs_mount_t *mp,
struct inode *parinode, /* parent inode pointer */
compat_xfs_fsop_handlereq_t *hreq,
struct inode **inode)
{ {
void __user *hanp; return xfs_handle_to_dentry(parfilp,
size_t hlen; compat_ptr(hreq->ihandle), hreq->ihandlen);
xfs_fid_t *xfid;
xfs_handle_t *handlep;
xfs_handle_t handle;
xfs_inode_t *ip;
xfs_ino_t ino;
__u32 igen;
int error;
/*
* Only allow handle opens under a directory.
*/
if (!S_ISDIR(parinode->i_mode))
return XFS_ERROR(ENOTDIR);
hanp = compat_ptr(hreq->ihandle);
hlen = hreq->ihandlen;
handlep = &handle;
if (hlen < sizeof(handlep->ha_fsid) || hlen > sizeof(*handlep))
return XFS_ERROR(EINVAL);
if (copy_from_user(handlep, hanp, hlen))
return XFS_ERROR(EFAULT);
if (hlen < sizeof(*handlep))
memset(((char *)handlep) + hlen, 0, sizeof(*handlep) - hlen);
if (hlen > sizeof(handlep->ha_fsid)) {
if (handlep->ha_fid.fid_len !=
(hlen - sizeof(handlep->ha_fsid) -
sizeof(handlep->ha_fid.fid_len)) ||
handlep->ha_fid.fid_pad)
return XFS_ERROR(EINVAL);
}
/*
* Crack the handle, obtain the inode # & generation #
*/
xfid = (struct xfs_fid *)&handlep->ha_fid;
if (xfid->fid_len == sizeof(*xfid) - sizeof(xfid->fid_len)) {
ino = xfid->fid_ino;
igen = xfid->fid_gen;
} else {
return XFS_ERROR(EINVAL);
}
/*
* Get the XFS inode, building a Linux inode to go with it.
*/
error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_SHARED, &ip, 0);
if (error)
return error;
if (ip == NULL)
return XFS_ERROR(EIO);
if (ip->i_d.di_gen != igen) {
xfs_iput_new(ip, XFS_ILOCK_SHARED);
return XFS_ERROR(ENOENT);
}
xfs_iunlock(ip, XFS_ILOCK_SHARED);
*inode = VFS_I(ip);
return 0;
} }
STATIC int STATIC int
xfs_compat_attrlist_by_handle( xfs_compat_attrlist_by_handle(
xfs_mount_t *mp, struct file *parfilp,
void __user *arg, void __user *arg)
struct inode *parinode)
{ {
int error; int error;
attrlist_cursor_kern_t *cursor; attrlist_cursor_kern_t *cursor;
compat_xfs_fsop_attrlist_handlereq_t al_hreq; compat_xfs_fsop_attrlist_handlereq_t al_hreq;
struct inode *inode; struct dentry *dentry;
char *kbuf; char *kbuf;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
...@@ -446,17 +375,17 @@ xfs_compat_attrlist_by_handle( ...@@ -446,17 +375,17 @@ xfs_compat_attrlist_by_handle(
if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE)) if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE))
return -XFS_ERROR(EINVAL); return -XFS_ERROR(EINVAL);
error = xfs_vget_fsop_handlereq_compat(mp, parinode, &al_hreq.hreq, dentry = xfs_compat_handlereq_to_dentry(parfilp, &al_hreq.hreq);
&inode); if (IS_ERR(dentry))
if (error) return PTR_ERR(dentry);
goto out;
error = -ENOMEM;
kbuf = kmalloc(al_hreq.buflen, GFP_KERNEL); kbuf = kmalloc(al_hreq.buflen, GFP_KERNEL);
if (!kbuf) if (!kbuf)
goto out_vn_rele; goto out_dput;
cursor = (attrlist_cursor_kern_t *)&al_hreq.pos; cursor = (attrlist_cursor_kern_t *)&al_hreq.pos;
error = xfs_attr_list(XFS_I(inode), kbuf, al_hreq.buflen, error = -xfs_attr_list(XFS_I(dentry->d_inode), kbuf, al_hreq.buflen,
al_hreq.flags, cursor); al_hreq.flags, cursor);
if (error) if (error)
goto out_kfree; goto out_kfree;
...@@ -466,22 +395,20 @@ xfs_compat_attrlist_by_handle( ...@@ -466,22 +395,20 @@ xfs_compat_attrlist_by_handle(
out_kfree: out_kfree:
kfree(kbuf); kfree(kbuf);
out_vn_rele: out_dput:
iput(inode); dput(dentry);
out: return error;
return -error;
} }
STATIC int STATIC int
xfs_compat_attrmulti_by_handle( xfs_compat_attrmulti_by_handle(
xfs_mount_t *mp, struct file *parfilp,
void __user *arg, void __user *arg)
struct inode *parinode)
{ {
int error; int error;
compat_xfs_attr_multiop_t *ops; compat_xfs_attr_multiop_t *ops;
compat_xfs_fsop_attrmulti_handlereq_t am_hreq; compat_xfs_fsop_attrmulti_handlereq_t am_hreq;
struct inode *inode; struct dentry *dentry;
unsigned int i, size; unsigned int i, size;
char *attr_name; char *attr_name;
...@@ -491,20 +418,19 @@ xfs_compat_attrmulti_by_handle( ...@@ -491,20 +418,19 @@ xfs_compat_attrmulti_by_handle(
sizeof(compat_xfs_fsop_attrmulti_handlereq_t))) sizeof(compat_xfs_fsop_attrmulti_handlereq_t)))
return -XFS_ERROR(EFAULT); return -XFS_ERROR(EFAULT);
error = xfs_vget_fsop_handlereq_compat(mp, parinode, &am_hreq.hreq, dentry = xfs_compat_handlereq_to_dentry(parfilp, &am_hreq.hreq);
&inode); if (IS_ERR(dentry))
if (error) return PTR_ERR(dentry);
goto out;
error = E2BIG; error = E2BIG;
size = am_hreq.opcount * sizeof(compat_xfs_attr_multiop_t); size = am_hreq.opcount * sizeof(compat_xfs_attr_multiop_t);
if (!size || size > 16 * PAGE_SIZE) if (!size || size > 16 * PAGE_SIZE)
goto out_vn_rele; goto out_dput;
error = ENOMEM; error = ENOMEM;
ops = kmalloc(size, GFP_KERNEL); ops = kmalloc(size, GFP_KERNEL);
if (!ops) if (!ops)
goto out_vn_rele; goto out_dput;
error = EFAULT; error = EFAULT;
if (copy_from_user(ops, compat_ptr(am_hreq.ops), size)) if (copy_from_user(ops, compat_ptr(am_hreq.ops), size))
...@@ -527,20 +453,29 @@ xfs_compat_attrmulti_by_handle( ...@@ -527,20 +453,29 @@ xfs_compat_attrmulti_by_handle(
switch (ops[i].am_opcode) { switch (ops[i].am_opcode) {
case ATTR_OP_GET: case ATTR_OP_GET:
ops[i].am_error = xfs_attrmulti_attr_get(inode, ops[i].am_error = xfs_attrmulti_attr_get(
attr_name, dentry->d_inode, attr_name,
compat_ptr(ops[i].am_attrvalue), compat_ptr(ops[i].am_attrvalue),
&ops[i].am_length, ops[i].am_flags); &ops[i].am_length, ops[i].am_flags);
break; break;
case ATTR_OP_SET: case ATTR_OP_SET:
ops[i].am_error = xfs_attrmulti_attr_set(inode, ops[i].am_error = mnt_want_write(parfilp->f_path.mnt);
attr_name, if (ops[i].am_error)
break;
ops[i].am_error = xfs_attrmulti_attr_set(
dentry->d_inode, attr_name,
compat_ptr(ops[i].am_attrvalue), compat_ptr(ops[i].am_attrvalue),
ops[i].am_length, ops[i].am_flags); ops[i].am_length, ops[i].am_flags);
mnt_drop_write(parfilp->f_path.mnt);
break; break;
case ATTR_OP_REMOVE: case ATTR_OP_REMOVE:
ops[i].am_error = xfs_attrmulti_attr_remove(inode, ops[i].am_error = mnt_want_write(parfilp->f_path.mnt);
attr_name, ops[i].am_flags); if (ops[i].am_error)
break;
ops[i].am_error = xfs_attrmulti_attr_remove(
dentry->d_inode, attr_name,
ops[i].am_flags);
mnt_drop_write(parfilp->f_path.mnt);
break; break;
default: default:
ops[i].am_error = EINVAL; ops[i].am_error = EINVAL;
...@@ -553,22 +488,20 @@ xfs_compat_attrmulti_by_handle( ...@@ -553,22 +488,20 @@ xfs_compat_attrmulti_by_handle(
kfree(attr_name); kfree(attr_name);
out_kfree_ops: out_kfree_ops:
kfree(ops); kfree(ops);
out_vn_rele: out_dput:
iput(inode); dput(dentry);
out:
return -error; return -error;
} }
STATIC int STATIC int
xfs_compat_fssetdm_by_handle( xfs_compat_fssetdm_by_handle(
xfs_mount_t *mp, struct file *parfilp,
void __user *arg, void __user *arg)
struct inode *parinode)
{ {
int error; int error;
struct fsdmidata fsd; struct fsdmidata fsd;
compat_xfs_fsop_setdm_handlereq_t dmhreq; compat_xfs_fsop_setdm_handlereq_t dmhreq;
struct inode *inode; struct dentry *dentry;
if (!capable(CAP_MKNOD)) if (!capable(CAP_MKNOD))
return -XFS_ERROR(EPERM); return -XFS_ERROR(EPERM);
...@@ -576,12 +509,11 @@ xfs_compat_fssetdm_by_handle( ...@@ -576,12 +509,11 @@ xfs_compat_fssetdm_by_handle(
sizeof(compat_xfs_fsop_setdm_handlereq_t))) sizeof(compat_xfs_fsop_setdm_handlereq_t)))
return -XFS_ERROR(EFAULT); return -XFS_ERROR(EFAULT);
error = xfs_vget_fsop_handlereq_compat(mp, parinode, &dmhreq.hreq, dentry = xfs_compat_handlereq_to_dentry(parfilp, &dmhreq.hreq);
&inode); if (IS_ERR(dentry))
if (error) return PTR_ERR(dentry);
return -error;
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) { if (IS_IMMUTABLE(dentry->d_inode) || IS_APPEND(dentry->d_inode)) {
error = -XFS_ERROR(EPERM); error = -XFS_ERROR(EPERM);
goto out; goto out;
} }
...@@ -591,11 +523,11 @@ xfs_compat_fssetdm_by_handle( ...@@ -591,11 +523,11 @@ xfs_compat_fssetdm_by_handle(
goto out; goto out;
} }
error = -xfs_set_dmattrs(XFS_I(inode), fsd.fsd_dmevmask, error = -xfs_set_dmattrs(XFS_I(dentry->d_inode), fsd.fsd_dmevmask,
fsd.fsd_dmstate); fsd.fsd_dmstate);
out: out:
iput(inode); dput(dentry);
return error; return error;
} }
...@@ -722,21 +654,21 @@ xfs_file_compat_ioctl( ...@@ -722,21 +654,21 @@ xfs_file_compat_ioctl(
if (xfs_compat_handlereq_copyin(&hreq, arg)) if (xfs_compat_handlereq_copyin(&hreq, arg))
return -XFS_ERROR(EFAULT); return -XFS_ERROR(EFAULT);
return xfs_open_by_handle(mp, &hreq, filp, inode); return xfs_open_by_handle(filp, &hreq);
} }
case XFS_IOC_READLINK_BY_HANDLE_32: { case XFS_IOC_READLINK_BY_HANDLE_32: {
struct xfs_fsop_handlereq hreq; struct xfs_fsop_handlereq hreq;
if (xfs_compat_handlereq_copyin(&hreq, arg)) if (xfs_compat_handlereq_copyin(&hreq, arg))
return -XFS_ERROR(EFAULT); return -XFS_ERROR(EFAULT);
return xfs_readlink_by_handle(mp, &hreq, inode); return xfs_readlink_by_handle(filp, &hreq);
} }
case XFS_IOC_ATTRLIST_BY_HANDLE_32: case XFS_IOC_ATTRLIST_BY_HANDLE_32:
return xfs_compat_attrlist_by_handle(mp, arg, inode); return xfs_compat_attrlist_by_handle(filp, arg);
case XFS_IOC_ATTRMULTI_BY_HANDLE_32: case XFS_IOC_ATTRMULTI_BY_HANDLE_32:
return xfs_compat_attrmulti_by_handle(mp, arg, inode); return xfs_compat_attrmulti_by_handle(filp, arg);
case XFS_IOC_FSSETDM_BY_HANDLE_32: case XFS_IOC_FSSETDM_BY_HANDLE_32:
return xfs_compat_fssetdm_by_handle(mp, arg, inode); return xfs_compat_fssetdm_by_handle(filp, arg);
default: default:
return -XFS_ERROR(ENOIOCTLCMD); return -XFS_ERROR(ENOIOCTLCMD);
} }
......
...@@ -1197,6 +1197,7 @@ xfs_fs_remount( ...@@ -1197,6 +1197,7 @@ xfs_fs_remount(
struct xfs_mount *mp = XFS_M(sb); struct xfs_mount *mp = XFS_M(sb);
substring_t args[MAX_OPT_ARGS]; substring_t args[MAX_OPT_ARGS];
char *p; char *p;
int error;
while ((p = strsep(&options, ",")) != NULL) { while ((p = strsep(&options, ",")) != NULL) {
int token; int token;
...@@ -1247,11 +1248,25 @@ xfs_fs_remount( ...@@ -1247,11 +1248,25 @@ xfs_fs_remount(
} }
} }
/* rw/ro -> rw */ /* ro -> rw */
if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) { if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) {
mp->m_flags &= ~XFS_MOUNT_RDONLY; mp->m_flags &= ~XFS_MOUNT_RDONLY;
if (mp->m_flags & XFS_MOUNT_BARRIER) if (mp->m_flags & XFS_MOUNT_BARRIER)
xfs_mountfs_check_barriers(mp); xfs_mountfs_check_barriers(mp);
/*
* If this is the first remount to writeable state we
* might have some superblock changes to update.
*/
if (mp->m_update_flags) {
error = xfs_mount_log_sb(mp, mp->m_update_flags);
if (error) {
cmn_err(CE_WARN,
"XFS: failed to write sb changes");
return error;
}
mp->m_update_flags = 0;
}
} }
/* rw -> ro */ /* rw -> ro */
......
...@@ -73,6 +73,8 @@ int xfs_dqreq_num; ...@@ -73,6 +73,8 @@ int xfs_dqreq_num;
int xfs_dqerror_mod = 33; int xfs_dqerror_mod = 33;
#endif #endif
static struct lock_class_key xfs_dquot_other_class;
/* /*
* Allocate and initialize a dquot. We don't always allocate fresh memory; * Allocate and initialize a dquot. We don't always allocate fresh memory;
* we try to reclaim a free dquot if the number of incore dquots are above * we try to reclaim a free dquot if the number of incore dquots are above
...@@ -141,6 +143,14 @@ xfs_qm_dqinit( ...@@ -141,6 +143,14 @@ xfs_qm_dqinit(
#endif #endif
} }
/*
* In either case we need to make sure group quotas have a different
* lock class than user quotas, to make sure lockdep knows we can
* locks of one of each at the same time.
*/
if (!(type & XFS_DQ_USER))
lockdep_set_class(&dqp->q_qlock, &xfs_dquot_other_class);
/* /*
* log item gets initialized later * log item gets initialized later
*/ */
...@@ -1383,6 +1393,12 @@ xfs_dqunlock_nonotify( ...@@ -1383,6 +1393,12 @@ xfs_dqunlock_nonotify(
mutex_unlock(&(dqp->q_qlock)); mutex_unlock(&(dqp->q_qlock));
} }
/*
* Lock two xfs_dquot structures.
*
* To avoid deadlocks we always lock the quota structure with
* the lowerd id first.
*/
void void
xfs_dqlock2( xfs_dqlock2(
xfs_dquot_t *d1, xfs_dquot_t *d1,
...@@ -1392,18 +1408,16 @@ xfs_dqlock2( ...@@ -1392,18 +1408,16 @@ xfs_dqlock2(
ASSERT(d1 != d2); ASSERT(d1 != d2);
if (be32_to_cpu(d1->q_core.d_id) > if (be32_to_cpu(d1->q_core.d_id) >
be32_to_cpu(d2->q_core.d_id)) { be32_to_cpu(d2->q_core.d_id)) {
xfs_dqlock(d2); mutex_lock(&d2->q_qlock);
xfs_dqlock(d1); mutex_lock_nested(&d1->q_qlock, XFS_QLOCK_NESTED);
} else { } else {
xfs_dqlock(d1); mutex_lock(&d1->q_qlock);
xfs_dqlock(d2); mutex_lock_nested(&d2->q_qlock, XFS_QLOCK_NESTED);
} }
} else { } else if (d1) {
if (d1) { mutex_lock(&d1->q_qlock);
xfs_dqlock(d1);
} else if (d2) { } else if (d2) {
xfs_dqlock(d2); mutex_lock(&d2->q_qlock);
}
} }
} }
......
...@@ -97,6 +97,16 @@ typedef struct xfs_dquot { ...@@ -97,6 +97,16 @@ typedef struct xfs_dquot {
#define dq_hashlist q_lists.dqm_hashlist #define dq_hashlist q_lists.dqm_hashlist
#define dq_flags q_lists.dqm_flags #define dq_flags q_lists.dqm_flags
/*
* Lock hierachy for q_qlock:
* XFS_QLOCK_NORMAL is the implicit default,
* XFS_QLOCK_NESTED is the dquot with the higher id in xfs_dqlock2
*/
enum {
XFS_QLOCK_NORMAL = 0,
XFS_QLOCK_NESTED,
};
#define XFS_DQHOLD(dqp) ((dqp)->q_nrefs++) #define XFS_DQHOLD(dqp) ((dqp)->q_nrefs++)
#ifdef DEBUG #ifdef DEBUG
......
...@@ -1070,6 +1070,13 @@ xfs_qm_sync( ...@@ -1070,6 +1070,13 @@ xfs_qm_sync(
return 0; return 0;
} }
/*
* The hash chains and the mplist use the same xfs_dqhash structure as
* their list head, but we can take the mplist qh_lock and one of the
* hash qh_locks at the same time without any problem as they aren't
* related.
*/
static struct lock_class_key xfs_quota_mplist_class;
/* /*
* This initializes all the quota information that's kept in the * This initializes all the quota information that's kept in the
...@@ -1105,6 +1112,8 @@ xfs_qm_init_quotainfo( ...@@ -1105,6 +1112,8 @@ xfs_qm_init_quotainfo(
} }
xfs_qm_list_init(&qinf->qi_dqlist, "mpdqlist", 0); xfs_qm_list_init(&qinf->qi_dqlist, "mpdqlist", 0);
lockdep_set_class(&qinf->qi_dqlist.qh_lock, &xfs_quota_mplist_class);
qinf->qi_dqreclaims = 0; qinf->qi_dqreclaims = 0;
/* mutex used to serialize quotaoffs */ /* mutex used to serialize quotaoffs */
......
...@@ -424,6 +424,19 @@ xfs_iformat( ...@@ -424,6 +424,19 @@ xfs_iformat(
case XFS_DINODE_FMT_LOCAL: case XFS_DINODE_FMT_LOCAL:
atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip); atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip);
size = be16_to_cpu(atp->hdr.totsize); size = be16_to_cpu(atp->hdr.totsize);
if (unlikely(size < sizeof(struct xfs_attr_sf_hdr))) {
xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount,
"corrupt inode %Lu "
"(bad attr fork size %Ld).",
(unsigned long long) ip->i_ino,
(long long) size);
XFS_CORRUPTION_ERROR("xfs_iformat(8)",
XFS_ERRLEVEL_LOW,
ip->i_mount, dip);
return XFS_ERROR(EFSCORRUPTED);
}
error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size); error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size);
break; break;
case XFS_DINODE_FMT_EXTENTS: case XFS_DINODE_FMT_EXTENTS:
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
#include "xfs_fsops.h" #include "xfs_fsops.h"
#include "xfs_utils.h" #include "xfs_utils.h"
STATIC int xfs_mount_log_sb(xfs_mount_t *, __int64_t);
STATIC int xfs_uuid_mount(xfs_mount_t *); STATIC int xfs_uuid_mount(xfs_mount_t *);
STATIC void xfs_unmountfs_wait(xfs_mount_t *); STATIC void xfs_unmountfs_wait(xfs_mount_t *);
...@@ -682,7 +681,7 @@ xfs_initialize_perag_data(xfs_mount_t *mp, xfs_agnumber_t agcount) ...@@ -682,7 +681,7 @@ xfs_initialize_perag_data(xfs_mount_t *mp, xfs_agnumber_t agcount)
* Update alignment values based on mount options and sb values * Update alignment values based on mount options and sb values
*/ */
STATIC int STATIC int
xfs_update_alignment(xfs_mount_t *mp, __uint64_t *update_flags) xfs_update_alignment(xfs_mount_t *mp)
{ {
xfs_sb_t *sbp = &(mp->m_sb); xfs_sb_t *sbp = &(mp->m_sb);
...@@ -736,11 +735,11 @@ xfs_update_alignment(xfs_mount_t *mp, __uint64_t *update_flags) ...@@ -736,11 +735,11 @@ xfs_update_alignment(xfs_mount_t *mp, __uint64_t *update_flags)
if (xfs_sb_version_hasdalign(sbp)) { if (xfs_sb_version_hasdalign(sbp)) {
if (sbp->sb_unit != mp->m_dalign) { if (sbp->sb_unit != mp->m_dalign) {
sbp->sb_unit = mp->m_dalign; sbp->sb_unit = mp->m_dalign;
*update_flags |= XFS_SB_UNIT; mp->m_update_flags |= XFS_SB_UNIT;
} }
if (sbp->sb_width != mp->m_swidth) { if (sbp->sb_width != mp->m_swidth) {
sbp->sb_width = mp->m_swidth; sbp->sb_width = mp->m_swidth;
*update_flags |= XFS_SB_WIDTH; mp->m_update_flags |= XFS_SB_WIDTH;
} }
} }
} else if ((mp->m_flags & XFS_MOUNT_NOALIGN) != XFS_MOUNT_NOALIGN && } else if ((mp->m_flags & XFS_MOUNT_NOALIGN) != XFS_MOUNT_NOALIGN &&
...@@ -905,7 +904,6 @@ xfs_mountfs( ...@@ -905,7 +904,6 @@ xfs_mountfs(
xfs_sb_t *sbp = &(mp->m_sb); xfs_sb_t *sbp = &(mp->m_sb);
xfs_inode_t *rip; xfs_inode_t *rip;
__uint64_t resblks; __uint64_t resblks;
__int64_t update_flags = 0LL;
uint quotamount, quotaflags; uint quotamount, quotaflags;
int uuid_mounted = 0; int uuid_mounted = 0;
int error = 0; int error = 0;
...@@ -933,7 +931,7 @@ xfs_mountfs( ...@@ -933,7 +931,7 @@ xfs_mountfs(
"XFS: correcting sb_features alignment problem"); "XFS: correcting sb_features alignment problem");
sbp->sb_features2 |= sbp->sb_bad_features2; sbp->sb_features2 |= sbp->sb_bad_features2;
sbp->sb_bad_features2 = sbp->sb_features2; sbp->sb_bad_features2 = sbp->sb_features2;
update_flags |= XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2; mp->m_update_flags |= XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2;
/* /*
* Re-check for ATTR2 in case it was found in bad_features2 * Re-check for ATTR2 in case it was found in bad_features2
...@@ -947,11 +945,11 @@ xfs_mountfs( ...@@ -947,11 +945,11 @@ xfs_mountfs(
if (xfs_sb_version_hasattr2(&mp->m_sb) && if (xfs_sb_version_hasattr2(&mp->m_sb) &&
(mp->m_flags & XFS_MOUNT_NOATTR2)) { (mp->m_flags & XFS_MOUNT_NOATTR2)) {
xfs_sb_version_removeattr2(&mp->m_sb); xfs_sb_version_removeattr2(&mp->m_sb);
update_flags |= XFS_SB_FEATURES2; mp->m_update_flags |= XFS_SB_FEATURES2;
/* update sb_versionnum for the clearing of the morebits */ /* update sb_versionnum for the clearing of the morebits */
if (!sbp->sb_features2) if (!sbp->sb_features2)
update_flags |= XFS_SB_VERSIONNUM; mp->m_update_flags |= XFS_SB_VERSIONNUM;
} }
/* /*
...@@ -960,7 +958,7 @@ xfs_mountfs( ...@@ -960,7 +958,7 @@ xfs_mountfs(
* allocator alignment is within an ag, therefore ag has * allocator alignment is within an ag, therefore ag has
* to be aligned at stripe boundary. * to be aligned at stripe boundary.
*/ */
error = xfs_update_alignment(mp, &update_flags); error = xfs_update_alignment(mp);
if (error) if (error)
goto error1; goto error1;
...@@ -1137,10 +1135,12 @@ xfs_mountfs( ...@@ -1137,10 +1135,12 @@ xfs_mountfs(
} }
/* /*
* If fs is not mounted readonly, then update the superblock changes. * If this is a read-only mount defer the superblock updates until
* the next remount into writeable mode. Otherwise we would never
* perform the update e.g. for the root filesystem.
*/ */
if (update_flags && !(mp->m_flags & XFS_MOUNT_RDONLY)) { if (mp->m_update_flags && !(mp->m_flags & XFS_MOUNT_RDONLY)) {
error = xfs_mount_log_sb(mp, update_flags); error = xfs_mount_log_sb(mp, mp->m_update_flags);
if (error) { if (error) {
cmn_err(CE_WARN, "XFS: failed to write sb changes"); cmn_err(CE_WARN, "XFS: failed to write sb changes");
goto error4; goto error4;
...@@ -1820,7 +1820,7 @@ xfs_uuid_mount( ...@@ -1820,7 +1820,7 @@ xfs_uuid_mount(
* be altered by the mount options, as well as any potential sb_features2 * be altered by the mount options, as well as any potential sb_features2
* fixup. Only the first superblock is updated. * fixup. Only the first superblock is updated.
*/ */
STATIC int int
xfs_mount_log_sb( xfs_mount_log_sb(
xfs_mount_t *mp, xfs_mount_t *mp,
__int64_t fields) __int64_t fields)
......
...@@ -327,6 +327,8 @@ typedef struct xfs_mount { ...@@ -327,6 +327,8 @@ typedef struct xfs_mount {
spinlock_t m_sync_lock; /* work item list lock */ spinlock_t m_sync_lock; /* work item list lock */
int m_sync_seq; /* sync thread generation no. */ int m_sync_seq; /* sync thread generation no. */
wait_queue_head_t m_wait_single_sync_task; wait_queue_head_t m_wait_single_sync_task;
__int64_t m_update_flags; /* sb flags we need to update
on the next remount,rw */
} xfs_mount_t; } xfs_mount_t;
/* /*
...@@ -512,6 +514,7 @@ extern int xfs_mod_incore_sb_unlocked(xfs_mount_t *, xfs_sb_field_t, ...@@ -512,6 +514,7 @@ extern int xfs_mod_incore_sb_unlocked(xfs_mount_t *, xfs_sb_field_t,
int64_t, int); int64_t, int);
extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *, extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *,
uint, int); uint, int);
extern int xfs_mount_log_sb(xfs_mount_t *, __int64_t);
extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int); extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int);
extern int xfs_readsb(xfs_mount_t *, int); extern int xfs_readsb(xfs_mount_t *, int);
extern void xfs_freesb(xfs_mount_t *); extern void xfs_freesb(xfs_mount_t *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment