Re: [RFC PATCH 3/4] xfs: add FREE_EOFBLOCKS ioctl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 27, 2012 at 03:51:50PM -0400, Brian Foster wrote:
> The XFS_IOC_FREE_EOFBLOCKS ioctl allows users to invoke an EOFBLOCKS
> scan. The xfs_eofblocks structure is defined to support the command
> parameters (quota type/id and minimum file size).
> 
> Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx>
> ---
>  fs/xfs/xfs_fs.h       |   10 ++++++++++
>  fs/xfs/xfs_ioctl.c    |   25 +++++++++++++++++++++++++
>  fs/xfs/xfs_quota.h    |    1 +
>  fs/xfs/xfs_quotaops.c |    2 +-
>  4 files changed, 37 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/xfs/xfs_fs.h b/fs/xfs/xfs_fs.h
> index c13fed8..6f93db9 100644
> --- a/fs/xfs/xfs_fs.h
> +++ b/fs/xfs/xfs_fs.h
> @@ -339,6 +339,15 @@ typedef struct xfs_error_injection {
>  
>  
>  /*
> + * Speculative preallocation trimming.
> + */
> +typedef struct xfs_eofblocks {
> +	__u32		id;		/* quota id */
> +	__u32		qtype;		/* quota type */
> +	__u64		min_file_size;	/* minimum file size */
> +} xfs_eofblocks_t;

No typedefs.

Additionally: this is a user facing API for functionality that has
wider potential use than quota. For example, xfs_fsr runs out of
space in an AG, but it really wants to put a file there, so it calls
XFS_IOC_FREE_EOFBLOCKS to specify the AG it wants all the prealloc
removed from.

So, the structure needs a version number so the kernel knows what
fields the application is aware of, a flags field to say what
operation is being done (i.e. flush by projid) rather than a "qtype"
and a bunch of padding so that we can add new elements to it as need
arises without breaking existing user binaries.

>   * ioctl commands that replace IRIX syssgi()'s
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 0e0232c..b91cbcd 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1602,6 +1602,31 @@ xfs_file_ioctl(
>  		error = xfs_errortag_clearall(mp, 1);
>  		return -error;
>  
> +	case XFS_IOC_FREE_EOFBLOCKS: {
> +		struct xfs_eofblocks eofb;
> +		int qtype;
> +
> +		if (copy_from_user(&eofb, arg, sizeof(eofb)))
> +			return -XFS_ERROR(EFAULT);
> +
> +		qtype = xfs_quota_type(eofb.qtype);
> +
> +		/*
> +		 * TODO: The filtering code currently uses the id in the inode.
> +		 * Therefore, I don't think it really matters whether the
> +		 * particular quota type is enabled (and the dquot is attached).
> +		 *
> +		 * Alternatively, we could filter by dquot type. This would
> +		 * mean we might have to make sure dquot's are attached during
> +		 * the scan and that the particular quota type is enabled. I'm
> +		 * not sure that this buys us anything.
> +		 */

If quota is not enabled, then a request to free blocks determined by
a quota ID is invalid and should be rejected. It's a user API - what
is and isn't supported needs to be written down in black and white
(i.e. in the xfsctl man page).

> +		/* TODO: might want to just use the eofb structure here */
> +		error = xfs_inodes_free_eofblocks(mp, qtype, eofb.id, eofb.min_file_size, EOFBLOCKS_WAIT);

Yes, just pass the structure - it means it can be passed all the way
down to the execute function, and only that code needs to handle
different versions of the structure.

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs


[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux