Skip to content

Commit 0b02c8c

Browse files
Dave ChinnerDarrick J. Wong
authored andcommitted
xfs: set prealloc flag in xfs_alloc_file_space()
Now that we only call xfs_update_prealloc_flags() from xfs_file_fallocate() in the case where we need to set the preallocation flag, do this in xfs_alloc_file_space() where we already have the inode joined into a transaction and get rid of the call to xfs_update_prealloc_flags() from the fallocate code. This also means that we now correctly avoid setting the XFS_DIFLAG_PREALLOC flag when xfs_is_always_cow_inode() is true, as these inodes will never have preallocated extents. Signed-off-by: Dave Chinner <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent fbe7e52 commit 0b02c8c

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

fs/xfs/xfs_bmap_util.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -850,9 +850,6 @@ xfs_alloc_file_space(
850850
rblocks = 0;
851851
}
852852

853-
/*
854-
* Allocate and setup the transaction.
855-
*/
856853
error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_write,
857854
dblocks, rblocks, false, &tp);
858855
if (error)
@@ -869,9 +866,9 @@ xfs_alloc_file_space(
869866
if (error)
870867
goto error;
871868

872-
/*
873-
* Complete the transaction
874-
*/
869+
ip->i_diflags |= XFS_DIFLAG_PREALLOC;
870+
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
871+
875872
error = xfs_trans_commit(tp);
876873
xfs_iunlock(ip, XFS_ILOCK_EXCL);
877874
if (error)

fs/xfs/xfs_file.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,6 @@ xfs_file_fallocate(
908908
struct inode *inode = file_inode(file);
909909
struct xfs_inode *ip = XFS_I(inode);
910910
long error;
911-
enum xfs_prealloc_flags flags = 0;
912911
uint iolock = XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL;
913912
loff_t new_size = 0;
914913
bool do_file_insert = false;
@@ -1006,8 +1005,6 @@ xfs_file_fallocate(
10061005
}
10071006
do_file_insert = true;
10081007
} else {
1009-
flags |= XFS_PREALLOC_SET;
1010-
10111008
if (!(mode & FALLOC_FL_KEEP_SIZE) &&
10121009
offset + len > i_size_read(inode)) {
10131010
new_size = offset + len;
@@ -1057,11 +1054,6 @@ xfs_file_fallocate(
10571054
if (error)
10581055
goto out_unlock;
10591056
}
1060-
1061-
error = xfs_update_prealloc_flags(ip, XFS_PREALLOC_SET);
1062-
if (error)
1063-
goto out_unlock;
1064-
10651057
}
10661058

10671059
/* Change file size if needed */

0 commit comments

Comments
 (0)