Skip to content

Commit ebbbf75

Browse files
committed
ntfs: Use new syncing helpers and update comments
Use new syncing helpers in .write and .aio_write functions. Also remove superfluous syncing in ntfs_file_buffered_write() and update comments about generic_osync_inode(). CC: Anton Altaparmakov <aia21@cantab.net> CC: linux-ntfs-dev@lists.sourceforge.net Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 0d34ec6 commit ebbbf75

2 files changed

Lines changed: 10 additions & 19 deletions

File tree

‎fs/ntfs/file.c‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,14 +2076,6 @@ static ssize_t ntfs_file_buffered_write(struct kiocb *iocb,
20762076
*ppos = pos;
20772077
if (cached_page)
20782078
page_cache_release(cached_page);
2079-
/* For now, when the user asks for O_SYNC, we actually give O_DSYNC. */
2080-
if (likely(!status)) {
2081-
if (unlikely((file->f_flags & O_SYNC) || IS_SYNC(vi))) {
2082-
if (!mapping->a_ops->writepage || !is_sync_kiocb(iocb))
2083-
status = generic_osync_inode(vi, mapping,
2084-
OSYNC_METADATA|OSYNC_DATA);
2085-
}
2086-
}
20872079
pagevec_lru_add_file(&lru_pvec);
20882080
ntfs_debug("Done. Returning %s (written 0x%lx, status %li).",
20892081
written ? "written" : "status", (unsigned long)written,
@@ -2145,8 +2137,8 @@ static ssize_t ntfs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
21452137
mutex_lock(&inode->i_mutex);
21462138
ret = ntfs_file_aio_write_nolock(iocb, iov, nr_segs, &iocb->ki_pos);
21472139
mutex_unlock(&inode->i_mutex);
2148-
if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
2149-
int err = sync_page_range(inode, mapping, pos, ret);
2140+
if (ret > 0) {
2141+
int err = generic_write_sync(file, pos, ret);
21502142
if (err < 0)
21512143
ret = err;
21522144
}
@@ -2173,8 +2165,8 @@ static ssize_t ntfs_file_writev(struct file *file, const struct iovec *iov,
21732165
if (ret == -EIOCBQUEUED)
21742166
ret = wait_on_sync_kiocb(&kiocb);
21752167
mutex_unlock(&inode->i_mutex);
2176-
if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
2177-
int err = sync_page_range(inode, mapping, *ppos - ret, ret);
2168+
if (ret > 0) {
2169+
int err = generic_write_sync(file, *ppos - ret, ret);
21782170
if (err < 0)
21792171
ret = err;
21802172
}

‎fs/ntfs/mft.c‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,12 @@ MFT_RECORD *map_extent_mft_record(ntfs_inode *base_ni, MFT_REF mref,
384384
* it is dirty in the inode meta data rather than the data page cache of the
385385
* inode, and thus there are no data pages that need writing out. Therefore, a
386386
* full mark_inode_dirty() is overkill. A mark_inode_dirty_sync(), on the
387-
* other hand, is not sufficient, because I_DIRTY_DATASYNC needs to be set to
388-
* ensure ->write_inode is called from generic_osync_inode() and this needs to
389-
* happen or the file data would not necessarily hit the device synchronously,
390-
* even though the vfs inode has the O_SYNC flag set. Also, I_DIRTY_DATASYNC
391-
* simply "feels" better than just I_DIRTY_SYNC, since the file data has not
392-
* actually hit the block device yet, which is not what I_DIRTY_SYNC on its own
393-
* would suggest.
387+
* other hand, is not sufficient, because ->write_inode needs to be called even
388+
* in case of fdatasync. This needs to happen or the file data would not
389+
* necessarily hit the device synchronously, even though the vfs inode has the
390+
* O_SYNC flag set. Also, I_DIRTY_DATASYNC simply "feels" better than just
391+
* I_DIRTY_SYNC, since the file data has not actually hit the block device yet,
392+
* which is not what I_DIRTY_SYNC on its own would suggest.
394393
*/
395394
void __mark_mft_record_dirty(ntfs_inode *ni)
396395
{

0 commit comments

Comments
 (0)