Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 73298
b: refs/heads/master
c: 9ea2d32
h: refs/heads/master
v: v3
  • Loading branch information
Mark Fasheh committed Nov 6, 2007
1 parent e00bae7 commit ad32778
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9f70968af3e6e21612e06e153aa71c62dee5a09b
refs/heads/master: 9ea2d32f40434589ea0e136373f7d1545afb411f
26 changes: 25 additions & 1 deletion trunk/fs/ocfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1891,9 +1891,11 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
ssize_t written = 0;
size_t ocount; /* original count */
size_t count; /* after file limit checks */
loff_t *ppos = &iocb->ki_pos;
loff_t old_size, *ppos = &iocb->ki_pos;
u32 old_clusters;
struct file *file = iocb->ki_filp;
struct inode *inode = file->f_path.dentry->d_inode;
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);

mlog_entry("(0x%p, %u, '%.*s')\n", file,
(unsigned int)nr_segs,
Expand Down Expand Up @@ -1949,6 +1951,13 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
goto relock;
}

/*
* To later detect whether a journal commit for sync writes is
* necessary, we sample i_size, and cluster count here.
*/
old_size = i_size_read(inode);
old_clusters = OCFS2_I(inode)->ip_clusters;

/* communicate with ocfs2_dio_end_io */
ocfs2_iocb_set_rw_locked(iocb, rw_level);

Expand Down Expand Up @@ -1978,6 +1987,21 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
/* buffered aio wouldn't have proper lock coverage today */
BUG_ON(ret == -EIOCBQUEUED && !(file->f_flags & O_DIRECT));

if ((file->f_flags & O_SYNC && !direct_io) || IS_SYNC(inode)) {
/*
* The generic write paths have handled getting data
* to disk, but since we don't make use of the dirty
* inode list, a manual journal commit is necessary
* here.
*/
if (old_size != i_size_read(inode) ||
old_clusters != OCFS2_I(inode)->ip_clusters) {
ret = journal_force_commit(osb->journal->j_journal);
if (ret < 0)
written = ret;
}
}

/*
* deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io
* function pointer which is called when o_direct io completes so that
Expand Down

0 comments on commit ad32778

Please sign in to comment.