[PATCH 1/4] libxfs: resync libxfs_alloc_file_space interface with the kernel

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

 



From: Darrick J. Wong <djwong@xxxxxxxxxx>

Make the userspace xfs_alloc_file_space behave (more or less) like the
kernel version, at least as far as the interface goes.

Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
---
 include/libxfs.h |    4 ++--
 libxfs/util.c    |   40 +++++++++++++++++++---------------------
 mkfs/proto.c     |    2 +-
 3 files changed, 22 insertions(+), 24 deletions(-)


diff --git a/include/libxfs.h b/include/libxfs.h
index b1e499569ac..d4985a5769f 100644
--- a/include/libxfs.h
+++ b/include/libxfs.h
@@ -167,8 +167,8 @@ extern int	libxfs_log_header(char *, uuid_t *, int, int, int, xfs_lsn_t,
 
 /* Shared utility routines */
 
-extern int	libxfs_alloc_file_space (struct xfs_inode *, xfs_off_t,
-				xfs_off_t, int, int);
+extern int	libxfs_alloc_file_space(struct xfs_inode *ip, xfs_off_t offset,
+					xfs_off_t len, int alloc_type);
 
 /* XXX: this is messy and needs fixing */
 #ifndef __LIBXFS_INTERNAL_XFS_H__
diff --git a/libxfs/util.c b/libxfs/util.c
index e8397fdc341..bb6867c21af 100644
--- a/libxfs/util.c
+++ b/libxfs/util.c
@@ -179,25 +179,23 @@ libxfs_mod_incore_sb(
  */
 int
 libxfs_alloc_file_space(
-	xfs_inode_t	*ip,
-	xfs_off_t	offset,
-	xfs_off_t	len,
-	int		alloc_type,
-	int		attr_flags)
+	struct xfs_inode	*ip,
+	xfs_off_t		offset,
+	xfs_off_t		len,
+	int			alloc_type)
 {
-	xfs_mount_t	*mp;
-	xfs_off_t	count;
-	xfs_filblks_t	datablocks;
-	xfs_filblks_t	allocated_fsb;
-	xfs_filblks_t	allocatesize_fsb;
-	xfs_bmbt_irec_t *imapp;
-	xfs_bmbt_irec_t imaps[1];
-	int		reccount;
-	uint		resblks;
-	xfs_fileoff_t	startoffset_fsb;
-	xfs_trans_t	*tp;
-	int		xfs_bmapi_flags;
-	int		error;
+	struct xfs_bmbt_irec	imaps[1];
+	struct xfs_bmbt_irec	*imapp;
+	struct xfs_mount	*mp;
+	struct xfs_trans	*tp;
+	xfs_off_t		count;
+	xfs_filblks_t		datablocks;
+	xfs_filblks_t		allocated_fsb;
+	xfs_filblks_t		allocatesize_fsb;
+	int			reccount;
+	uint			resblks;
+	xfs_fileoff_t		startoffset_fsb;
+	int			error;
 
 	if (len <= 0)
 		return -EINVAL;
@@ -206,7 +204,6 @@ libxfs_alloc_file_space(
 	error = 0;
 	imapp = &imaps[0];
 	reccount = 1;
-	xfs_bmapi_flags = alloc_type ? XFS_BMAPI_PREALLOC : 0;
 	mp = ip->i_mount;
 	startoffset_fsb = XFS_B_TO_FSBT(mp, offset);
 	allocatesize_fsb = XFS_B_TO_FSB(mp, count);
@@ -227,8 +224,9 @@ libxfs_alloc_file_space(
 		}
 		xfs_trans_ijoin(tp, ip, 0);
 
-		error = xfs_bmapi_write(tp, ip, startoffset_fsb, allocatesize_fsb,
-				xfs_bmapi_flags, 0, imapp, &reccount);
+		error = xfs_bmapi_write(tp, ip, startoffset_fsb,
+				allocatesize_fsb, alloc_type, resblks,
+				imapp, &reccount);
 
 		if (error)
 			goto error0;
diff --git a/mkfs/proto.c b/mkfs/proto.c
index 36af61ed5c0..b11b7fa5f95 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -179,7 +179,7 @@ rsvfile(
 	int		error;
 	xfs_trans_t	*tp;
 
-	error = -libxfs_alloc_file_space(ip, 0, llen, 1, 0);
+	error = -libxfs_alloc_file_space(ip, 0, llen, XFS_BMAPI_PREALLOC);
 
 	if (error) {
 		fail(_("error reserving space for a file"), error);




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux