diff options
-rw-r--r-- | fs/xfs/xfs_file.c | 31 | ||||
-rw-r--r-- | fs/xfs/xfs_trace.h | 1 |
2 files changed, 31 insertions, 1 deletions
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 0b600b51778c..753ed9b5c70b 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c | |||
@@ -124,6 +124,35 @@ xfs_iozero( | |||
124 | return (-status); | 124 | return (-status); |
125 | } | 125 | } |
126 | 126 | ||
127 | /* | ||
128 | * Fsync operations on directories are much simpler than on regular files, | ||
129 | * as there is no file data to flush, and thus also no need for explicit | ||
130 | * cache flush operations, and there are no non-transaction metadata updates | ||
131 | * on directories either. | ||
132 | */ | ||
133 | STATIC int | ||
134 | xfs_dir_fsync( | ||
135 | struct file *file, | ||
136 | loff_t start, | ||
137 | loff_t end, | ||
138 | int datasync) | ||
139 | { | ||
140 | struct xfs_inode *ip = XFS_I(file->f_mapping->host); | ||
141 | struct xfs_mount *mp = ip->i_mount; | ||
142 | xfs_lsn_t lsn = 0; | ||
143 | |||
144 | trace_xfs_dir_fsync(ip); | ||
145 | |||
146 | xfs_ilock(ip, XFS_ILOCK_SHARED); | ||
147 | if (xfs_ipincount(ip)) | ||
148 | lsn = ip->i_itemp->ili_last_lsn; | ||
149 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | ||
150 | |||
151 | if (!lsn) | ||
152 | return 0; | ||
153 | return _xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL); | ||
154 | } | ||
155 | |||
127 | STATIC int | 156 | STATIC int |
128 | xfs_file_fsync( | 157 | xfs_file_fsync( |
129 | struct file *file, | 158 | struct file *file, |
@@ -1140,7 +1169,7 @@ const struct file_operations xfs_dir_file_operations = { | |||
1140 | #ifdef CONFIG_COMPAT | 1169 | #ifdef CONFIG_COMPAT |
1141 | .compat_ioctl = xfs_file_compat_ioctl, | 1170 | .compat_ioctl = xfs_file_compat_ioctl, |
1142 | #endif | 1171 | #endif |
1143 | .fsync = xfs_file_fsync, | 1172 | .fsync = xfs_dir_fsync, |
1144 | }; | 1173 | }; |
1145 | 1174 | ||
1146 | static const struct vm_operations_struct xfs_file_vm_ops = { | 1175 | static const struct vm_operations_struct xfs_file_vm_ops = { |
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index bb5e660e0fab..b78f2c65438b 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h | |||
@@ -576,6 +576,7 @@ DEFINE_INODE_EVENT(xfs_vm_bmap); | |||
576 | DEFINE_INODE_EVENT(xfs_file_ioctl); | 576 | DEFINE_INODE_EVENT(xfs_file_ioctl); |
577 | DEFINE_INODE_EVENT(xfs_file_compat_ioctl); | 577 | DEFINE_INODE_EVENT(xfs_file_compat_ioctl); |
578 | DEFINE_INODE_EVENT(xfs_ioctl_setattr); | 578 | DEFINE_INODE_EVENT(xfs_ioctl_setattr); |
579 | DEFINE_INODE_EVENT(xfs_dir_fsync); | ||
579 | DEFINE_INODE_EVENT(xfs_file_fsync); | 580 | DEFINE_INODE_EVENT(xfs_file_fsync); |
580 | DEFINE_INODE_EVENT(xfs_destroy_inode); | 581 | DEFINE_INODE_EVENT(xfs_destroy_inode); |
581 | DEFINE_INODE_EVENT(xfs_write_inode); | 582 | DEFINE_INODE_EVENT(xfs_write_inode); |