Commit 8f45cdd9 authored by Timothy Shimmin's avatar Timothy Shimmin Committed by Nathan Scott

[XFS] Add XFS_FS_GOINGDOWN interface to xfs.

SGI Modid: xfs-linux:xfs-kern:166489a
parent 23d5a8c1
......@@ -699,9 +699,7 @@ xfs_ioctl(
error = xfs_set_dmattrs(bdp, dmi.fsd_dmevmask, dmi.fsd_dmstate,
NULL);
if (error)
return -error;
return 0;
}
case XFS_IOC_GETBMAP:
......@@ -733,9 +731,7 @@ xfs_ioctl(
case XFS_IOC_SWAPEXT: {
error = xfs_swapext((struct xfs_swapext *)arg);
if (error)
return -error;
return 0;
}
case XFS_IOC_FSCOUNTS: {
......@@ -763,6 +759,8 @@ xfs_ioctl(
/* input parameter is passed in resblks field of structure */
in = inout.resblks;
error = xfs_reserve_blocks(mp, &in, &inout);
if (error)
return -error;
if (copy_to_user((char *)arg, &inout, sizeof(inout)))
return -XFS_ERROR(EFAULT);
......@@ -795,9 +793,7 @@ xfs_ioctl(
return -XFS_ERROR(EFAULT);
error = xfs_growfs_data(mp, &in);
if (error)
return -error;
return 0;
}
case XFS_IOC_FSGROWFSLOG: {
......@@ -810,9 +806,7 @@ xfs_ioctl(
return -XFS_ERROR(EFAULT);
error = xfs_growfs_log(mp, &in);
if (error)
return -error;
return 0;
}
case XFS_IOC_FSGROWFSRT: {
......@@ -825,9 +819,7 @@ xfs_ioctl(
return -XFS_ERROR(EFAULT);
error = xfs_growfs_rt(mp, &in);
if (error)
return -error;
return 0;
}
case XFS_IOC_FREEZE:
......@@ -842,6 +834,19 @@ xfs_ioctl(
xfs_fs_thaw(mp);
return 0;
case XFS_IOC_GOINGDOWN: {
__uint32_t in;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
if (get_user(in, (__uint32_t *)arg))
return -XFS_ERROR(EFAULT);
error = xfs_fs_goingdown(mp, in);
return -error;
}
case XFS_IOC_ERROR_INJECTION: {
xfs_error_injection_t in;
......@@ -849,9 +854,7 @@ xfs_ioctl(
return -XFS_ERROR(EFAULT);
error = xfs_errortag_add(in.errtag, mp);
if (error)
return -error;
return 0;
}
case XFS_IOC_ERROR_CLEARALL:
......
......@@ -437,6 +437,12 @@ typedef struct xfs_handle {
#define FSHSIZE sizeof(fsid_t)
/*
* Flags for going down operation
*/
#define XFS_FSOP_GOING_FLAGS_DEFAULT 0x0 /* going down */
#define XFS_FSOP_GOING_FLAGS_LOGFLUSH 0x1 /* flush log but not data */
#define XFS_FSOP_GOING_FLAGS_NOLOGFLUSH 0x2 /* don't flush log nor data */
/*
* ioctl commands that replace IRIX fcntl()'s
......@@ -490,6 +496,7 @@ typedef struct xfs_handle {
#define XFS_IOC_ATTRLIST_BY_HANDLE _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq)
#define XFS_IOC_ATTRMULTI_BY_HANDLE _IOW ('X', 123, struct xfs_fsop_attrmulti_handlereq)
#define XFS_IOC_FSGEOMETRY _IOR ('X', 124, struct xfs_fsop_geom)
#define XFS_IOC_GOINGDOWN _IOR ('X', 125, __uint32_t)
/* XFS_IOC_GETFSUUID ---------- deprecated 140 */
......
......@@ -626,3 +626,28 @@ xfs_fs_thaw(
xfs_finish_freeze(mp);
return 0;
}
int
xfs_fs_goingdown(
xfs_mount_t *mp,
__uint32_t inflags)
{
switch (inflags)
{
case XFS_FSOP_GOING_FLAGS_DEFAULT:
xfs_fs_freeze(mp);
xfs_force_shutdown(mp, XFS_FORCE_UMOUNT);
xfs_fs_thaw(mp);
break;
case XFS_FSOP_GOING_FLAGS_LOGFLUSH:
xfs_force_shutdown(mp, XFS_FORCE_UMOUNT);
break;
case XFS_FSOP_GOING_FLAGS_NOLOGFLUSH:
xfs_force_shutdown(mp, XFS_FORCE_UMOUNT|XFS_LOG_IO_ERROR);
break;
default:
return XFS_ERROR(EINVAL);
}
return 0;
}
......@@ -67,4 +67,9 @@ int
xfs_fs_thaw(
xfs_mount_t *mp);
int
xfs_fs_goingdown(
xfs_mount_t *mp,
__uint32_t inflags);
#endif /* __XFS_FSOPS_H__ */
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