Skip to content

Commit b39a046

Browse files
Dave ChinnerDarrick J. Wong
authored andcommitted
xfs: move xfs_update_prealloc_flags() to xfs_pnfs.c
The operations that xfs_update_prealloc_flags() perform are now unique to xfs_fs_map_blocks(), so move xfs_update_prealloc_flags() to be a static function in xfs_pnfs.c and cut out all the other functionality that is doesn't use anymore. Signed-off-by: Dave Chinner <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 0b02c8c commit b39a046

File tree

3 files changed

+36
-42
lines changed

3 files changed

+36
-42
lines changed

fs/xfs/xfs_file.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -66,38 +66,6 @@ xfs_is_falloc_aligned(
6666
return !((pos | len) & mask);
6767
}
6868

69-
int
70-
xfs_update_prealloc_flags(
71-
struct xfs_inode *ip,
72-
enum xfs_prealloc_flags flags)
73-
{
74-
struct xfs_trans *tp;
75-
int error;
76-
77-
error = xfs_trans_alloc(ip->i_mount, &M_RES(ip->i_mount)->tr_writeid,
78-
0, 0, 0, &tp);
79-
if (error)
80-
return error;
81-
82-
xfs_ilock(ip, XFS_ILOCK_EXCL);
83-
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
84-
85-
if (!(flags & XFS_PREALLOC_INVISIBLE)) {
86-
VFS_I(ip)->i_mode &= ~S_ISUID;
87-
if (VFS_I(ip)->i_mode & S_IXGRP)
88-
VFS_I(ip)->i_mode &= ~S_ISGID;
89-
xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
90-
}
91-
92-
if (flags & XFS_PREALLOC_SET)
93-
ip->i_diflags |= XFS_DIFLAG_PREALLOC;
94-
if (flags & XFS_PREALLOC_CLEAR)
95-
ip->i_diflags &= ~XFS_DIFLAG_PREALLOC;
96-
97-
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
98-
return xfs_trans_commit(tp);
99-
}
100-
10169
/*
10270
* Fsync operations on directories are much simpler than on regular files,
10371
* as there is no file data to flush, and thus also no need for explicit

fs/xfs/xfs_inode.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -462,14 +462,6 @@ xfs_itruncate_extents(
462462
}
463463

464464
/* from xfs_file.c */
465-
enum xfs_prealloc_flags {
466-
XFS_PREALLOC_SET = (1 << 1),
467-
XFS_PREALLOC_CLEAR = (1 << 2),
468-
XFS_PREALLOC_INVISIBLE = (1 << 3),
469-
};
470-
471-
int xfs_update_prealloc_flags(struct xfs_inode *ip,
472-
enum xfs_prealloc_flags flags);
473465
int xfs_break_layouts(struct inode *inode, uint *iolock,
474466
enum layout_break_reason reason);
475467

fs/xfs/xfs_pnfs.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,40 @@ xfs_fs_get_uuid(
7070
return 0;
7171
}
7272

73+
/*
74+
* We cannot use file based VFS helpers such as file_modified() to update
75+
* inode state as we modify the data/metadata in the inode here. Hence we have
76+
* to open code the timestamp updates and SUID/SGID stripping. We also need
77+
* to set the inode prealloc flag to ensure that the extents we allocate are not
78+
* removed if the inode is reclaimed from memory before xfs_fs_block_commit()
79+
* is from the client to indicate that data has been written and the file size
80+
* can be extended.
81+
*/
82+
static int
83+
xfs_fs_map_update_inode(
84+
struct xfs_inode *ip)
85+
{
86+
struct xfs_trans *tp;
87+
int error;
88+
89+
error = xfs_trans_alloc(ip->i_mount, &M_RES(ip->i_mount)->tr_writeid,
90+
0, 0, 0, &tp);
91+
if (error)
92+
return error;
93+
94+
xfs_ilock(ip, XFS_ILOCK_EXCL);
95+
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
96+
97+
VFS_I(ip)->i_mode &= ~S_ISUID;
98+
if (VFS_I(ip)->i_mode & S_IXGRP)
99+
VFS_I(ip)->i_mode &= ~S_ISGID;
100+
xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
101+
ip->i_diflags |= XFS_DIFLAG_PREALLOC;
102+
103+
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
104+
return xfs_trans_commit(tp);
105+
}
106+
73107
/*
74108
* Get a layout for the pNFS client.
75109
*/
@@ -164,7 +198,7 @@ xfs_fs_map_blocks(
164198
* that the blocks allocated and handed out to the client are
165199
* guaranteed to be present even after a server crash.
166200
*/
167-
error = xfs_update_prealloc_flags(ip, XFS_PREALLOC_SET);
201+
error = xfs_fs_map_update_inode(ip);
168202
if (!error)
169203
error = xfs_log_force_inode(ip);
170204
if (error)
@@ -257,7 +291,7 @@ xfs_fs_commit_blocks(
257291
length = end - start;
258292
if (!length)
259293
continue;
260-
294+
261295
/*
262296
* Make sure reads through the pagecache see the new data.
263297
*/

0 commit comments

Comments
 (0)